void execute() { TApp *app = TApp::instance(); ToonzScene *scene = app->getCurrentScene()->getScene(); TLevelSet *levelSet = scene->getLevelSet(); std::set<TXshLevel *> usedLevels; scene->getTopXsheet()->getUsedLevels(usedLevels); std::vector<TXshLevel *> unused; for (int i = 0; i < levelSet->getLevelCount(); i++) { TXshLevel *xl = levelSet->getLevel(i); if (usedLevels.count(xl) == 0) unused.push_back(xl); } if (unused.empty()) { DVGui::error(QObject::tr("No unused levels")); return; } else { TUndoManager *um = TUndoManager::manager(); um->beginBlock(); for (int i = 0; i < (int)unused.size(); i++) { TXshLevel *xl = unused[i]; um->add(new DeleteLevelUndo(xl)); scene->getLevelSet()->removeLevel(xl); } TApp::instance()->getCurrentXsheet()->notifyXsheetChanged(); TApp::instance()->getCurrentScene()->notifyCastChange(); um->endBlock(); } }
PaletteViewerPanel::PaletteViewerPanel(QWidget *parent) : TPanel(parent) { m_paletteHandle = new TPaletteHandle(); connect(m_paletteHandle, SIGNAL(colorStyleSwitched()), SLOT(onColorStyleSwitched())); connect(m_paletteHandle, SIGNAL(paletteSwitched()), SLOT(onPaletteSwitched())); TApp *app = TApp::instance(); m_paletteViewer = new PaletteViewer(this, PaletteViewerGUI::LEVEL_PALETTE); m_paletteViewer->setPaletteHandle( app->getPaletteController()->getCurrentLevelPalette()); m_paletteViewer->setFrameHandle(app->getCurrentFrame()); m_paletteViewer->setXsheetHandle(app->getCurrentXsheet()); // for clearing cache when paste style command called from the StyleSelection m_paletteViewer->setLevelHandle(app->getCurrentLevel()); TSceneHandle *sceneHandle = app->getCurrentScene(); connect(sceneHandle, SIGNAL(sceneSwitched()), SLOT(onSceneSwitched())); CurrentStyleChangeCommand *currentStyleChangeCommand = new CurrentStyleChangeCommand(); m_paletteViewer->setChangeStyleCommand(currentStyleChangeCommand); setWidget(m_paletteViewer); initializeTitleBar(); }
void SchematicScenePanel::hideEvent(QHideEvent *e) { TApp *app = TApp::instance(); disconnect(m_schematicViewer, SIGNAL(showPreview(TFxP)), this, SLOT(onShowPreview(TFxP))); disconnect(m_schematicViewer, SIGNAL(doCollapse(const QList<TFxP> &)), this, SLOT(onCollapse(const QList<TFxP> &))); disconnect(m_schematicViewer, SIGNAL(doCollapse(QList<TStageObjectId>)), this, SLOT(onCollapse(QList<TStageObjectId>))); disconnect(m_schematicViewer, SIGNAL(doExplodeChild(const QList<TFxP> &)), this, SLOT(onExplodeChild(const QList<TFxP> &))); disconnect(m_schematicViewer, SIGNAL(doExplodeChild(QList<TStageObjectId>)), this, SLOT(onExplodeChild(QList<TStageObjectId>))); disconnect(m_schematicViewer, SIGNAL(editObject()), this, SLOT(onEditObject())); disconnect(app->getCurrentLevel(), SIGNAL(xshLevelChanged()), m_schematicViewer, SLOT(updateScenes())); disconnect(app->getCurrentObject(), SIGNAL(objectSwitched()), m_schematicViewer, SLOT(updateScenes())); disconnect(app->getCurrentXsheet(), SIGNAL(xsheetSwitched()), m_schematicViewer, SLOT(updateSchematic())); disconnect(app->getCurrentXsheet(), SIGNAL(xsheetChanged()), m_schematicViewer, SLOT(updateSchematic())); disconnect(app->getCurrentScene(), SIGNAL(sceneSwitched()), m_schematicViewer, SLOT(onSceneSwitched())); }
void SchematicScenePanel::showEvent(QShowEvent *e) { if (m_schematicViewer->isStageSchematicViewed()) setWindowTitle("Stage Schematic"); else setWindowTitle("Fx Schematic"); TApp *app = TApp::instance(); connect(m_schematicViewer, SIGNAL(showPreview(TFxP)), this, SLOT(onShowPreview(TFxP))); connect(m_schematicViewer, SIGNAL(doCollapse(const QList<TFxP> &)), this, SLOT(onCollapse(const QList<TFxP> &))); connect(m_schematicViewer, SIGNAL(doCollapse(QList<TStageObjectId>)), this, SLOT(onCollapse(QList<TStageObjectId>))); connect(m_schematicViewer, SIGNAL(doExplodeChild(const QList<TFxP> &)), this, SLOT(onExplodeChild(const QList<TFxP> &))); connect(m_schematicViewer, SIGNAL(doExplodeChild(QList<TStageObjectId>)), this, SLOT(onExplodeChild(QList<TStageObjectId>))); connect(m_schematicViewer, SIGNAL(editObject()), this, SLOT(onEditObject())); connect(app->getCurrentLevel(), SIGNAL(xshLevelChanged()), m_schematicViewer, SLOT(updateScenes())); connect(app->getCurrentObject(), SIGNAL(objectSwitched()), m_schematicViewer, SLOT(updateScenes())); connect(app->getCurrentXsheet(), SIGNAL(xsheetSwitched()), m_schematicViewer, SLOT(updateSchematic())); connect(app->getCurrentXsheet(), SIGNAL(xsheetChanged()), m_schematicViewer, SLOT(updateSchematic())); connect(app->getCurrentScene(), SIGNAL(sceneSwitched()), m_schematicViewer, SLOT(onSceneSwitched())); m_schematicViewer->updateSchematic(); }
FxParamEditorPopup::FxParamEditorPopup() : QDialog(TApp::instance()->getMainWindow()) { setWindowTitle(tr("Fx Settings")); setMinimumSize(20, 20); TApp *app = TApp::instance(); TSceneHandle *hScene = app->getCurrentScene(); TPixel32 col1, col2; Preferences::instance()->getChessboardColors(col1, col2); FxSettings *fxSettings = new FxSettings(this, col1, col2); fxSettings->setSceneHandle(hScene); fxSettings->setFxHandle(app->getCurrentFx()); fxSettings->setFrameHandle(app->getCurrentFrame()); fxSettings->setXsheetHandle(app->getCurrentXsheet()); fxSettings->setLevelHandle(app->getCurrentLevel()); fxSettings->setObjectHandle(app->getCurrentObject()); fxSettings->setCurrentFx(); QVBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->setMargin(0); mainLayout->setSpacing(10); { mainLayout->addWidget(fxSettings); } setLayout(mainLayout); move(parentWidget()->geometry().center() - rect().bottomRight() / 2.0); }
TFx *InsertFxPopup::createFx() { TApp *app = TApp::instance(); ToonzScene *scene = app->getCurrentScene()->getScene(); TXsheet *xsh = scene->getXsheet(); QTreeWidgetItem *item = m_fxTree->currentItem(); QString text = item->data(0, Qt::UserRole).toString(); if (text.isEmpty()) return 0; TFx *fx; TFilePath path = TFilePath(text.toStdWString()); if (TFileStatus(path).doesExist() && TFileStatus(path.getParentDir()).isDirectory()) { std::string folder = path.getParentDir().getName(); if (folder == "macroFx") //Devo caricare una macro fx = createMacroFxByPath(path); else //Verifico se devo caricare un preset { folder = path.getParentDir().getParentDir().getName(); if (folder == "presets") //Devo caricare un preset fx = createPresetFxByName(path); } } else fx = createFxByName(text.toStdString()); if (fx) return fx; else return 0; }
void LayerHeaderPanel::mouseReleaseEvent(QMouseEvent *event) { TApp *app = TApp::instance(); TXsheet *xsh = m_viewer->getXsheet(); int col, totcols = xsh->getColumnCount(); bool sound_changed = false; if (m_doOnRelease != 0 && totcols > 0) { for (col = 0; col < totcols; col++) { if (!xsh->isColumnEmpty(col)) { TXshColumn *column = xsh->getColumn(col); if (m_doOnRelease == ToggleAllPreviewVisible) { column->setPreviewVisible(!column->isPreviewVisible()); } else if (m_doOnRelease == ToggleAllTransparency) { column->setCamstandVisible(!column->isCamstandVisible()); if (column->getSoundColumn()) sound_changed = true; } else if (m_doOnRelease == ToggleAllLock) { column->lock(!column->isLocked()); } } } if (sound_changed) { app->getCurrentXsheet()->notifyXsheetSoundChanged(); } app->getCurrentScene()->notifySceneChanged(); app->getCurrentXsheet()->notifyXsheetChanged(); } m_viewer->updateColumnArea(); update(); m_doOnRelease = 0; }
void RowArea::mousePressEvent(QMouseEvent *event) { m_viewer->setQtModifiers(event->modifiers()); if (event->button() == Qt::LeftButton) { bool playRangeModifierisClicked = false; TApp *app = TApp::instance(); TXsheet *xsh = app->getCurrentScene()->getScene()->getXsheet(); TPoint pos(event->pos().x(), event->pos().y()); int row = m_viewer->yToRow(pos.y); QRect visibleRect = visibleRegion().boundingRect(); int playR0, playR1, step; XsheetGUI::getPlayRange(playR0, playR1, step); bool playRangeEnabled = playR0 <= playR1; if (!playRangeEnabled) { TXsheet *xsh = m_viewer->getXsheet(); playR1 = xsh->getFrameCount() - 1; playR0 = 0; } if (playR1 == -1) { //getFrameCount = 0 i.e. xsheet is empty setDragTool(XsheetGUI::DragTool::makeCurrentFrameModifierTool(m_viewer)); } else if (m_xa <= pos.x && pos.x <= m_xa + 10 && (row == playR0 || row == playR1)) { if (!playRangeEnabled) XsheetGUI::setPlayRange(playR0, playR1, step); setDragTool(XsheetGUI::DragTool::makePlayRangeModifierTool(m_viewer)); playRangeModifierisClicked = true; } else setDragTool(XsheetGUI::DragTool::makeCurrentFrameModifierTool(m_viewer)); //when shift+click the row area, select a single row region in the cell area if (!playRangeModifierisClicked && 0 != (event->modifiers() & Qt::ShiftModifier)) { int filledCol; for (filledCol = xsh->getColumnCount() - 1; filledCol >= 0; filledCol--) { TXshColumn *currentColumn = xsh->getColumn(filledCol); if (!currentColumn) continue; if (!currentColumn->isEmpty()) break; } m_viewer->getCellSelection()->selectNone(); m_viewer->getCellSelection()->selectCells(row, 0, row, tmax(0, filledCol)); m_viewer->updateCellRowAree(); } m_viewer->dragToolClick(event); event->accept(); } // left-click // pan by middle-drag else if (event->button() == Qt::MidButton) { m_pos = event->pos(); m_isPanning = true; } }
void FunctionViewerPanel::attachHandles() { TApp *app = TApp::instance(); m_functionViewer->setXsheetHandle(app->getCurrentXsheet()); m_functionViewer->setFrameHandle(app->getCurrentFrame()); m_functionViewer->setObjectHandle(app->getCurrentObject()); m_functionViewer->setFxHandle(app->getCurrentFx()); m_functionViewer->setColumnHandle(app->getCurrentColumn()); m_functionViewer->setSceneHandle(app->getCurrentScene()); }
void onDeliver() { if (m_error) { m_error = false; MsgBox(DVGui::CRITICAL, QObject::tr("There was an error saving frames for the %1 level.").arg(QString::fromStdWString(m_fp.withoutParentDir().getWideString()))); } bool isPreview = (m_fp.getType() == "noext"); TImageCache::instance()->remove(toString(m_fp.getWideString() + L".0")); TNotifier::instance()->notify(TSceneNameChange()); if (Preferences::instance()->isGeneratedMovieViewEnabled()) { if (!isPreview && (Preferences::instance()->isDefaultViewerEnabled()) && (m_fp.getType() == "mov" || m_fp.getType() == "avi" || m_fp.getType() == "3gp")) { QString name = QString::fromStdString(m_fp.getName()); int index; if ((index = name.indexOf("#RENDERID")) != -1) //!quite ugly I know.... m_fp = m_fp.withName(name.left(index).toStdWString()); if (!TSystem::showDocument(m_fp)) { QString msg(QObject::tr("It is not possible to display the file %1: no player associated with its format").arg(QString::fromStdWString(m_fp.withoutParentDir().getWideString()))); MsgBox(WARNING, msg); } } else { int r0, r1, step; TApp *app = TApp::instance(); ToonzScene *scene = app->getCurrentScene()->getScene(); TOutputProperties &outputSettings = isPreview ? *scene->getProperties()->getPreviewProperties() : *scene->getProperties()->getOutputProperties(); outputSettings.getRange(r0, r1, step); const TRenderSettings rs = outputSettings.getRenderSettings(); if (r0 == 0 && r1 == -1) r0 = 0, r1 = scene->getFrameCount() - 1; double timeStretchFactor = isPreview ? 1.0 : (double)outputSettings.getRenderSettings().m_timeStretchTo / outputSettings.getRenderSettings().m_timeStretchFrom; r0 = tfloor(r0 * timeStretchFactor); r1 = tceil((r1 + 1) * timeStretchFactor) - 1; TXsheet::SoundProperties *prop = new TXsheet::SoundProperties(); prop->m_frameRate = outputSettings.getFrameRate(); TSoundTrack *snd = app->getCurrentXsheet()->getXsheet()->makeSound(prop); if (outputSettings.getRenderSettings().m_stereoscopic) { assert(!isPreview); ::viewFile(m_fp.withName(m_fp.getName() + "_l"), r0 + 1, r1 + 1, step, isPreview ? rs.m_shrinkX : 1, snd, 0, false, true); ::viewFile(m_fp.withName(m_fp.getName() + "_r"), r0 + 1, r1 + 1, step, isPreview ? rs.m_shrinkX : 1, snd, 0, false, true); } else ::viewFile(m_fp, r0 + 1, r1 + 1, step, isPreview ? rs.m_shrinkX : 1, snd, 0, false, true); } } }
void ComboViewerPanel::hideEvent(QHideEvent *) { TApp *app = TApp::instance(); disconnect(app->getCurrentScene()); disconnect(app->getCurrentLevel()); disconnect(app->getCurrentFrame()); disconnect(app->getCurrentObject()); disconnect(app->getCurrentXsheet()); disconnect(app->getCurrentTool()); m_flipConsole->setActive(false); }
void TColumnSelection::hideColumns() { TApp *app = TApp::instance(); ColumnFan *columnFan = app->getCurrentXsheet()->getXsheet()->getColumnFan(); std::set<int>::iterator it = m_indices.begin(); for (; it != m_indices.end(); ++it) columnFan->deactivate(*it); m_indices.clear(); app->getCurrentXsheet()->notifyXsheetChanged(); // DA FARE (non c'e una notica per il solo cambiamento della testa delle // colonne) // TApp::instance()->->notify(TColumnHeadChange()); app->getCurrentScene()->setDirtyFlag(true); }
void InsertEmptyColumnsUndo::undo() const { TApp *app = TApp::instance(); TXsheet *xsh = app->getCurrentXsheet()->getXsheet(); std::vector<std::pair<int, int>>::const_iterator bt, bEnd = m_columnBlocks.end(); for (bt = m_columnBlocks.begin(); bt != bEnd; ++bt) for (int n = 0; n != bt->second; ++n) xsh->removeColumn(bt->first); app->getCurrentScene()->setDirtyFlag(true); app->getCurrentXsheet()->notifyXsheetChanged(); app->getCurrentObject()->notifyObjectIdSwitched(); }
bool removeLevel(TXshLevel *level) { TApp *app = TApp::instance(); ToonzScene *scene = app->getCurrentScene()->getScene(); if (scene->getChildStack()->getTopXsheet()->isLevelUsed(level)) DVGui::error(QObject::tr("It is not possible to delete the used level %1.").arg(QString::fromStdWString(level->getName()))); //"E_CantDeleteUsedLevel_%1" else { TUndoManager *um = TUndoManager::manager(); um->add(new DeleteLevelUndo(level)); scene->getLevelSet()->removeLevel(level); } return true; }
void ComboViewerPanel::hideEvent(QHideEvent *event) { StyleShortcutSwitchablePanel::hideEvent(event); TApp *app = TApp::instance(); disconnect(app->getCurrentFrame(), 0, this, 0); disconnect(app->getCurrentScene(), 0, this, 0); disconnect(app->getCurrentLevel(), 0, this, 0); disconnect(app->getCurrentObject(), 0, this, 0); disconnect(app->getCurrentXsheet(), 0, this, 0); disconnect(app->getCurrentTool(), SIGNAL(toolSwitched()), m_sceneViewer, SLOT(onToolSwitched())); m_flipConsole->setActive(false); }
void InsertEmptyColumnsUndo::redo() const { TApp *app = TApp::instance(); TXsheet *xsh = app->getCurrentXsheet()->getXsheet(); // If this is the very first column, add one now since there is always // 1 visible on the screen but its not actually there yet. if (!xsh->getColumnCount()) xsh->insertColumn(0); std::vector<std::pair<int, int>>::const_reverse_iterator bt, bEnd = m_columnBlocks.rend(); for (bt = m_columnBlocks.rbegin(); bt != bEnd; ++bt) for (int n = 0; n != bt->second; ++n) xsh->insertColumn(bt->first); app->getCurrentScene()->setDirtyFlag(true); app->getCurrentXsheet()->notifyXsheetChanged(); app->getCurrentObject()->notifyObjectIdSwitched(); }
void TStyleSelection::toggleLink() { if (!m_palette || m_pageIndex < 0) return; int n = m_styleIndicesInPage.size(); if (n <= 0) return; bool somethingHasBeenLinked = false; bool currentStyleIsInSelection = false; TApp *app = TApp::instance(); TPaletteHandle *ph = app->getCurrentPalette(); TPalette::Page *page = m_palette->getPage(m_pageIndex); assert(page); for (std::set<int>::iterator it = m_styleIndicesInPage.begin(); it != m_styleIndicesInPage.end(); ++it) { TColorStyle *cs = page->getStyle(*it); assert(cs); wstring name = cs->getGlobalName(); if (name != L"" && (name[0] == L'-' || name[0] == L'+')) { name[0] = name[0] == L'-' ? L'+' : L'-'; cs->setGlobalName(name); if (name[0] == L'+') somethingHasBeenLinked = true; } if (*it == m_palette->getPage(m_pageIndex)->search(ph->getStyleIndex())) currentStyleIsInSelection = true; } if (somethingHasBeenLinked) StudioPalette::instance()->updateLinkedColors(m_palette.getPointer()); ph->notifyPaletteChanged(); if (currentStyleIsInSelection) ph->notifyColorStyleSwitched(); // DA FARE: e' giusto mettere la nofica del dirty flag a current scene // o e' meglio farlo al livello corrente!? app->getCurrentScene()->setDirtyFlag(true); // extern void setPaletteDirtyFlag(); // setPaletteDirtyFlag(); }
void BinarizePopup::fetchSample() { TApp *app = TApp::instance(); TImageP img; if (app->getCurrentFrame()->isEditingLevel()) { TXshLevel *xshLevel = app->getCurrentLevel()->getLevel(); if (xshLevel && xshLevel->getSimpleLevel()) { TXshSimpleLevel *sl = xshLevel->getSimpleLevel(); img = sl->getFrame(app->getCurrentFrame()->getFid(), false); } } else { TXsheet *xsh = app->getCurrentScene()->getScene()->getXsheet(); TXshCell cell = xsh->getCell(app->getCurrentFrame()->getFrame(), app->getCurrentColumn()->getColumnIndex()); img = cell.getImage(false); } TRasterImageP ri = img; if (ri) { setSample(ri->getRaster()); } else { setSample(TRasterP()); } }
ComboViewerPanel::ComboViewerPanel(QWidget *parent, Qt::WFlags flags) #endif : TPanel(parent) { TApp *app = TApp::instance(); QFrame *hbox = new QFrame(this); hbox->setFrameStyle(QFrame::StyledPanel); hbox->setObjectName("ComboViewerPanel"); // ToolBar m_toolbar = new Toolbar(this, false); // Tool Options m_toolOptions = new ToolOptions(); m_toolOptions->setObjectName("ComboViewerToolOptions"); // Viewer ImageUtils::FullScreenWidget *fsWidget = new ImageUtils::FullScreenWidget(this); fsWidget->setWidget(m_sceneViewer = new SceneViewer(fsWidget)); #if defined(Q_OS_WIN) && (QT_VERSION >= 0x050500) && (QT_VERSION < 0x050600) // Workaround for QTBUG-48288 // This code should be removed after updating Qt. // Qt may crash in handling WM_SIZE of m_sceneViewer in splash.finish(&w) // in main.cpp. To suppress sending WM_SIZE, set window position here. // WM_SIZE will not be sent if window poistion is not changed. ::SetWindowPos(reinterpret_cast<HWND>(m_sceneViewer->winId()), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); #endif m_vRuler = new Ruler(this, m_sceneViewer, true); m_hRuler = new Ruler(this, m_sceneViewer, false); m_sceneViewer->setRulers(m_vRuler, m_hRuler); m_keyFrameButton = new ViewerKeyframeNavigator(this, app->getCurrentFrame()); m_keyFrameButton->setObjectHandle(app->getCurrentObject()); m_keyFrameButton->setXsheetHandle(app->getCurrentXsheet()); // FlipConsole int buttons = FlipConsole::cFullConsole; buttons &= (~FlipConsole::eSound); buttons &= (~FlipConsole::eFilledRaster); buttons &= (~FlipConsole::eDefineLoadBox); buttons &= (~FlipConsole::eUseLoadBox); /* --- layout --- */ QVBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->setMargin(0); mainLayout->setSpacing(0); { mainLayout->addWidget(m_toolbar, 0); mainLayout->addWidget(m_toolOptions, 0); QGridLayout *viewerL = new QGridLayout(); viewerL->setMargin(0); viewerL->setSpacing(0); { viewerL->addWidget(m_vRuler, 1, 0); viewerL->addWidget(m_hRuler, 0, 1); viewerL->addWidget(fsWidget, 1, 1); } mainLayout->addLayout(viewerL, 1); m_flipConsole = new FlipConsole(mainLayout, buttons, false, m_keyFrameButton, "SceneViewerConsole", this, true); } hbox->setLayout(mainLayout); setWidget(hbox); m_flipConsole->enableButton(FlipConsole::eMatte, false, false); m_flipConsole->enableButton(FlipConsole::eSave, false, false); m_flipConsole->enableButton(FlipConsole::eCompare, false, false); m_flipConsole->enableButton(FlipConsole::eSaveImg, false, false); m_flipConsole->enableButton(FlipConsole::eGRed, false, false); m_flipConsole->enableButton(FlipConsole::eGGreen, false, false); m_flipConsole->enableButton(FlipConsole::eGBlue, false, false); m_flipConsole->enableButton(FlipConsole::eSound, false, true); m_flipConsole->setFrameRate(app->getCurrentScene() ->getScene() ->getProperties() ->getOutputProperties() ->getFrameRate()); m_flipConsole->setFrameHandle(TApp::instance()->getCurrentFrame()); bool ret = true; // When zoom changed, only if the viewer is active, change window title. ret = connect(m_sceneViewer, SIGNAL(onZoomChanged()), SLOT(changeWindowTitle())); ret = ret && connect(m_sceneViewer, SIGNAL(previewToggled()), SLOT(changeWindowTitle())); ret = ret && connect(m_flipConsole, SIGNAL(playStateChanged(bool)), TApp::instance()->getCurrentFrame(), SLOT(setPlaying(bool))); ret = ret && connect(m_flipConsole, SIGNAL(buttonPressed(FlipConsole::EGadget)), m_sceneViewer, SLOT(onButtonPressed(FlipConsole::EGadget))); ret = ret && connect(m_sceneViewer, SIGNAL(previewStatusChanged()), this, SLOT(update())); ret = ret && connect(app->getCurrentScene(), SIGNAL(sceneSwitched()), this, SLOT(onSceneSwitched())); assert(ret); // note: initializeTitleBar() refers to m_sceneViewer initializeTitleBar(getTitleBar()); // initial state of the parts m_visibleFlag[CVPARTS_TOOLBAR] = true; m_visibleFlag[CVPARTS_TOOLOPTIONS] = true; m_visibleFlag[CVPARTS_FLIPCONSOLE] = true; updateShowHide(); }
void RowArea::drawOnionSkinSelection(QPainter &p) { TApp *app = TApp::instance(); OnionSkinMask osMask = app->getCurrentOnionSkin()->getOnionSkinMask(); TXsheet *xsh = app->getCurrentScene()->getScene()->getXsheet(); assert(xsh); int currentRow = m_viewer->getCurrentRow(); // get onion colors TPixel frontPixel, backPixel; bool inksOnly; Preferences::instance()->getOnionData(frontPixel, backPixel, inksOnly); QColor frontColor((int)frontPixel.r, (int)frontPixel.g, (int)frontPixel.b, 128); QColor backColor((int)backPixel.r, (int)backPixel.g, (int)backPixel.b, 128); int onionDotDiam = 8; int onionHandleDiam = RowHeight - 1; int onionDotYPos = (RowHeight - onionDotDiam) / 2; // If the onion skin is disabled, draw dash line instead. if (osMask.isEnabled()) p.setPen(Qt::red); else { QPen currentPen = p.pen(); currentPen.setStyle(Qt::DashLine); currentPen.setColor(QColor(128, 128, 128, 255)); p.setPen(currentPen); } // Draw onion skin extender handles. QRectF handleRect(3, m_viewer->rowToY(currentRow) + 1, onionHandleDiam, onionHandleDiam); int angle180 = 16 * 180; p.setBrush(QBrush(backColor)); p.drawChord(handleRect, 0, angle180); p.setBrush(QBrush(frontColor)); p.drawChord(handleRect, angle180, angle180); //-- draw movable onions // draw line between onion skin range int minMos = 0; int maxMos = 0; int mosCount = osMask.getMosCount(); for (int i = 0; i < mosCount; i++) { int mos = osMask.getMos(i); if (minMos > mos) minMos = mos; if (maxMos < mos) maxMos = mos; } p.setBrush(Qt::NoBrush); if (minMos < 0) // previous frames { int y0 = m_viewer->rowToY(currentRow + minMos) + onionDotYPos + onionDotDiam; int y1 = m_viewer->rowToY(currentRow); p.drawLine(onionDotDiam*1.5, y0, onionDotDiam*1.5, y1); } if (maxMos > 0) // foward frames { int y0 = m_viewer->rowToY(currentRow + 1); int y1 = m_viewer->rowToY(currentRow + maxMos) + onionDotYPos; p.drawLine(onionDotDiam*1.5, y0, onionDotDiam*1.5, y1); } // draw onion skin dots p.setPen(Qt::red); for (int i = 0; i < mosCount; i++) { // mos : frame offset from the current frame int mos = osMask.getMos(i); // skip drawing if the frame is under the mouse cursor if (m_showOnionToSet == Mos && currentRow + mos == m_row) continue; int y = m_viewer->rowToY(currentRow + mos) + onionDotYPos; if (osMask.isEnabled()) p.setBrush(mos < 0 ? backColor : frontColor); else p.setBrush(Qt::NoBrush); p.drawEllipse(onionDotDiam, y, onionDotDiam, onionDotDiam); } //-- draw fixed onions for (int i = 0; i < osMask.getFosCount(); i++) { int fos = osMask.getFos(i); if (fos == currentRow) continue; // skip drawing if the frame is under the mouse cursor if (m_showOnionToSet == Fos && fos == m_row) continue; int y = m_viewer->rowToY(fos) + onionDotYPos; if (osMask.isEnabled()) p.setBrush(QBrush(QColor(0, 255, 255, 128))); else p.setBrush(Qt::NoBrush); p.drawEllipse(0, y, onionDotDiam, onionDotDiam); } //-- draw highlighted onion if (m_showOnionToSet != None) { int y = m_viewer->rowToY(m_row) + onionDotYPos; int xPos = (m_showOnionToSet == Fos) ? 0 : onionDotDiam; p.setPen(QColor(255, 128, 0)); p.setBrush(QBrush(QColor(255, 255, 0, 200))); p.drawEllipse(xPos, y, onionDotDiam, onionDotDiam); } }
bool LevelCreatePopup::apply() { TApp *app = TApp::instance(); int row = app->getCurrentFrame()->getFrame(); int col = app->getCurrentColumn()->getColumnIndex(); int i, j; ToonzScene *scene = app->getCurrentScene()->getScene(); TXsheet *xsh = scene->getXsheet(); bool validColumn = true; if (xsh->getColumn(col)) validColumn = xsh->getColumn(col)->getColumnType() == TXshColumn::eLevelType; int from = (int)m_fromFld->getValue(); int to = (int)m_toFld->getValue(); int inc = (int)m_incFld->getValue(); int step = (int)m_stepFld->getValue(); double w = m_widthFld->getValue(); double h = m_heightFld->getValue(); double dpi = m_dpiFld->getValue(); int xres = std::max(tround(w * dpi), 1); int yres = std::max(tround(h * dpi), 1); int lType = getLevelType(); std::wstring levelName = m_nameFld->text().toStdWString(); // tolgo i blanks prima e dopo i = levelName.find_first_not_of(L' '); if (i == (int)std::wstring::npos) levelName = L""; else { int j = levelName.find_last_not_of(L' '); assert(j != (int)std::wstring::npos); levelName = levelName.substr(i, j - i + 1); } if (levelName.empty()) { error(tr("No level name specified: please choose a valid level name")); return false; } if (from > to) { error(tr("Invalid frame range")); return false; } if (inc <= 0) { error(tr("Invalid increment value")); return false; } if (step <= 0) { error(tr("Invalid step value")); return false; } int numFrames = step * (((to - from) / inc) + 1); if (scene->getLevelSet()->getLevel(levelName)) { error( tr("The level name specified is already used: please choose a " "different level name")); m_nameFld->selectAll(); return false; } TFilePath parentDir(m_pathFld->getPath().toStdWString()); TFilePath fp = scene->getDefaultLevelPath(lType, levelName).withParentDir(parentDir); TFilePath actualFp = scene->decodeFilePath(fp); if (TSystem::doesExistFileOrLevel(actualFp)) { error( tr("The level name specified is already used: please choose a " "different level name")); m_nameFld->selectAll(); return false; } parentDir = scene->decodeFilePath(parentDir); if (!TFileStatus(parentDir).doesExist()) { QString question; /*question = "Folder " +toQString(parentDir) + " doesn't exist.\nDo you want to create it?";*/ question = tr("Folder %1 doesn't exist.\nDo you want to create it?") .arg(toQString(parentDir)); int ret = DVGui::MsgBox(question, QObject::tr("Yes"), QObject::tr("No")); if (ret == 0 || ret == 2) return false; try { TSystem::mkDir(parentDir); DvDirModel::instance()->refreshFolder(parentDir.getParentDir()); } catch (...) { error(tr("Unable to create") + toQString(parentDir)); return false; } } TXshLevel *level = scene->createNewLevel(lType, levelName, TDimension(), 0, fp); TXshSimpleLevel *sl = dynamic_cast<TXshSimpleLevel *>(level); assert(sl); sl->setPath(fp, true); if (lType == TZP_XSHLEVEL || lType == OVL_XSHLEVEL) { sl->getProperties()->setDpiPolicy(LevelProperties::DP_ImageDpi); sl->getProperties()->setDpi(dpi); sl->getProperties()->setImageDpi(TPointD(dpi, dpi)); sl->getProperties()->setImageRes(TDimension(xres, yres)); } /*-- これからLevelを配置しようとしているセルが空いているかどうかのチェック * --*/ bool areColumnsShifted = false; TXshCell cell = xsh->getCell(row, col); bool isInRange = true; for (i = row; i < row + numFrames; i++) { if (!cell.isEmpty()) { isInRange = false; break; } cell = xsh->getCell(i, col); } if (!validColumn) { isInRange = false; } /*-- 別のLevelに占有されていた場合、Columnを1つ右に移動 --*/ if (!isInRange) { col += 1; TApp::instance()->getCurrentColumn()->setColumnIndex(col); areColumnsShifted = true; xsh->insertColumn(col); } CreateLevelUndo *undo = new CreateLevelUndo(row, col, numFrames, step, areColumnsShifted); TUndoManager::manager()->add(undo); for (i = from; i <= to; i += inc) { TFrameId fid(i); TXshCell cell(sl, fid); if (lType == PLI_XSHLEVEL) sl->setFrame(fid, new TVectorImage()); else if (lType == TZP_XSHLEVEL) { TRasterCM32P raster(xres, yres); raster->fill(TPixelCM32()); TToonzImageP ti(raster, TRect()); ti->setDpi(dpi, dpi); sl->setFrame(fid, ti); ti->setSavebox(TRect(0, 0, xres - 1, yres - 1)); } else if (lType == OVL_XSHLEVEL) { TRaster32P raster(xres, yres); raster->clear(); TRasterImageP ri(raster); ri->setDpi(dpi, dpi); sl->setFrame(fid, ri); } for (j = 0; j < step; j++) xsh->setCell(row++, col, cell); } if (lType == TZP_XSHLEVEL || lType == OVL_XSHLEVEL) { sl->save(fp); DvDirModel::instance()->refreshFolder(fp.getParentDir()); } undo->onAdd(sl); app->getCurrentScene()->notifySceneChanged(); app->getCurrentScene()->notifyCastChange(); app->getCurrentXsheet()->notifyXsheetChanged(); // Cambia l'immagine corrente ma non cambiano ne' il frame ne' la colonna // corrente // (entrambi notificano il cambiamento dell'immagine al tool). // devo verfificare che sia settato il tool giusto. app->getCurrentTool()->onImageChanged( (TImage::Type)app->getCurrentImageType()); return true; }
void ComboViewerPanel::showEvent(QShowEvent *) { TApp *app = TApp::instance(); TFrameHandle *frameHandle = app->getCurrentFrame(); TSceneHandle *sceneHandle = app->getCurrentScene(); TXshLevelHandle *levelHandle = app->getCurrentLevel(); TObjectHandle *objectHandle = app->getCurrentObject(); TXsheetHandle *xshHandle = app->getCurrentXsheet(); bool ret = true; /*! onSceneChanged(): called when the scene changed - set new scene's FPS - update the range of frame slider with a new framehandle - set the marker - update key frames */ ret = connect(xshHandle, SIGNAL(xsheetChanged()), this, SLOT(onSceneChanged())); ret = ret && connect(sceneHandle, SIGNAL(sceneSwitched()), this, SLOT(onSceneChanged())); ret = ret && connect(sceneHandle, SIGNAL(sceneChanged()), this, SLOT(onSceneChanged())); /*! changeWindowTitle(): called when the scene / level / frame is changed - chenge the title text */ ret = ret && connect(sceneHandle, SIGNAL(nameSceneChanged()), this, SLOT(changeWindowTitle())); ret = ret && connect(levelHandle, SIGNAL(xshLevelChanged()), this, SLOT(changeWindowTitle())); ret = ret && connect(frameHandle, SIGNAL(frameSwitched()), this, SLOT(changeWindowTitle())); // onXshLevelSwitched(TXshLevel*): changeWindowTitle() + updateFrameRange() ret = ret && connect(levelHandle, SIGNAL(xshLevelSwitched(TXshLevel *)), this, SLOT(onXshLevelSwitched(TXshLevel *))); // updateFrameRange(): update the frame slider's range ret = ret && connect(levelHandle, SIGNAL(xshLevelChanged()), this, SLOT(updateFrameRange())); // onFrameTypeChanged(): reset the marker positions in the flip console ret = ret && connect(frameHandle, SIGNAL(frameTypeChanged()), this, SLOT(onFrameTypeChanged())); // onFrameChanged(): update the flipconsole according to the current frame ret = ret && connect(frameHandle, SIGNAL(frameSwitched()), this, SLOT(onFrameChanged())); ret = ret && connect(app->getCurrentTool(), SIGNAL(toolSwitched()), m_sceneViewer, SLOT(onToolSwitched())); ret = ret && connect(sceneHandle, SIGNAL(preferenceChanged()), m_flipConsole, SLOT(onPreferenceChanged())); m_flipConsole->onPreferenceChanged(); assert(ret); m_flipConsole->setActive(true); // refresh onSceneChanged(); changeWindowTitle(); }
void RowArea::drawOnionSkinSelection(QPainter &p) { TApp *app = TApp::instance(); OnionSkinMask osMask = app->getCurrentOnionSkin()->getOnionSkinMask(); TXsheet *xsh = app->getCurrentScene()->getScene()->getXsheet(); assert(xsh); int currentRow = m_viewer->getCurrentRow(); if (m_showOnionToSet) { int y = m_viewer->rowToY(m_row) + 3; QRect rect(m_xa - 6, y + 1, 4, 4); p.setPen(m_viewer->getDarkLineColor()); p.drawRect(rect); p.fillRect(rect.adjusted(1, 1, 0, 0), QBrush(m_viewer->getLightLineColor())); } if (!osMask.isEnabled()) return; int i; for (i = 0; i < osMask.getFosCount(); i++) { int fos = osMask.getFos(i); if (fos == currentRow) continue; int y = m_viewer->rowToY(fos) + 3; QRect rect(m_xa - 6, y + 1, 4, 4); p.setPen(Qt::black); p.drawRect(rect); p.fillRect(rect.adjusted(1, 1, 0, 0), QBrush(m_viewer->getDarkLineColor())); } int lastY; int xc = m_xa - 10; #ifndef STUDENT int mosCount = osMask.getMosCount(); for (i = 0; i < mosCount; i++) { int mos = osMask.getMos(i); int y = m_viewer->rowToY(currentRow + mos) + 3; QRect rect(m_xa - 12, y + 1, 4, 4); p.setPen(Qt::black); p.drawRect(rect); p.fillRect(rect.adjusted(1, 1, 0, 0), QBrush(m_viewer->getLightLineColor())); if (i > 0 || mos > 0) { int ya = y; int yb; if (i == 0 || mos > 0 && osMask.getMos(i - 1) < 0) yb = m_viewer->rowToY(currentRow) + RowHeight; else yb = lastY + 5; p.setPen(Qt::black); p.drawLine(xc, ya, xc, yb); } lastY = y; if (mos < 0 && (i == mosCount - 1 || osMask.getMos(i + 1) > 0)) { int ya = m_viewer->rowToY(currentRow); int yb = lastY + 5; p.setPen(Qt::black); p.drawLine(xc, ya, xc, yb); } } #endif }
void ComboViewerPanel::changeWindowTitle() { TApp *app = TApp::instance(); ToonzScene *scene = app->getCurrentScene()->getScene(); if (!scene) return; int frame = app->getCurrentFrame()->getFrame(); // put the titlebar texts in this string QString name; // if the frame type is "scene editing" if (app->getCurrentFrame()->isEditingScene()) { QString sceneName = QString::fromStdWString(scene->getSceneName()); if (sceneName.isEmpty()) sceneName = tr("Untitled"); if (app->getCurrentScene()->getDirtyFlag()) sceneName += QString(" *"); name = tr("Scene: ") + sceneName; if (frame >= 0) name = name + tr(" :: Frame: ") + tr(std::to_string(frame + 1).c_str()); int col = app->getCurrentColumn()->getColumnIndex(); if (col < 0) { setWindowTitle(name); return; } TXsheet *xsh = app->getCurrentXsheet()->getXsheet(); TXshCell cell = xsh->getCell(frame, col); if (cell.isEmpty()) { setWindowTitle(name); return; } assert(cell.m_level.getPointer()); TFilePath fp(cell.m_level->getName()); QString imageName = QString::fromStdWString(fp.withFrame(cell.m_frameId).getWideString()); name = name + tr(" :: Level: ") + imageName; if (m_sceneViewer->isPreviewEnabled()) { name = name + " :: Zoom : " + QString::number((int)(100.0 * sqrt(m_sceneViewer->getViewMatrix().det()) * m_sceneViewer->getDpiFactor())) + "%"; } // If the current level exists and some option is set in the preference, // set the zoom value to the current level's dpi else if (Preferences::instance() ->isActualPixelViewOnSceneEditingModeEnabled() && TApp::instance()->getCurrentLevel()->getSimpleLevel() && !CleanupPreviewCheck::instance() ->isEnabled() // cleanup preview must be OFF && !CameraTestCheck::instance() ->isEnabled()) // camera test mode must be OFF neither { name = name + " :: Zoom : " + QString::number((int)(100.0 * sqrt(m_sceneViewer->getViewMatrix().det()) * m_sceneViewer->getDpiFactor())) + "%"; } } // if the frame type is "level editing" else { TXshLevel *level = app->getCurrentLevel()->getLevel(); if (level) { TFilePath fp(level->getName()); QString imageName = QString::fromStdWString( fp.withFrame(app->getCurrentFrame()->getFid()).getWideString()); name = name + tr("Level: ") + imageName; name = name + " :: Zoom : " + QString::number((int)(100.0 * sqrt(m_sceneViewer->getViewMatrix().det()) * m_sceneViewer->getDpiFactor())) + "%"; } } setWindowTitle(name); }