void SceneViewer::enterEvent(QEvent *) { if (m_isMouseEntered) return; m_isMouseEntered = true; TApp *app = TApp::instance(); modifiers = 0; TTool *tool = app->getCurrentTool()->getTool(); TXshLevel *level = app->getCurrentLevel()->getLevel(); if (level && level->getSimpleLevel()) m_dpiScale = getCurrentDpiScale(level->getSimpleLevel(), tool->getCurrentFid()); else m_dpiScale = TPointD(1, 1); if (m_freezedStatus != NO_FREEZED) return; invalidateToolStatus(); if (tool && tool->isEnabled()) { tool->setViewer(this); tool->updateMatrix(); tool->onEnter(); } setFocus(); updateGL(); }
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 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); } }
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 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); } } }
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 FunctionViewerPanel::onEditObject() { TApp *app = TApp::instance(); app->getCurrentTool()->setTool(T_Edit); }
void SchematicScenePanel::onEditObject() { TApp *app = TApp::instance(); app->getCurrentTool()->setTool(T_Edit); }
SceneViewerContextMenu::SceneViewerContextMenu(SceneViewer *parent) : QMenu(parent), m_viewer(parent), m_groupIndexToBeEntered(-1) { TApp *app = TApp::instance(); bool isEditingLevel = app->getCurrentFrame()->isEditingLevel(); bool ret = true; QAction *action = 0; CommandManager *commandManager = CommandManager::instance(); /*- サブカメラの消去 -*/ if (parent->isEditPreviewSubcamera()) { action = addAction(tr("Reset Subcamera")); ret = ret && parent->connect(action, SIGNAL(triggered()), SLOT(doDeleteSubCamera())); addSeparator(); } // tool TTool *tool = app->getCurrentTool()->getTool(); if (tool && tool->isEnabled()) tool->addContextMenuItems(this); // fullscreen if (ImageUtils::FullScreenWidget *fsWidget = dynamic_cast<ImageUtils::FullScreenWidget *>( m_viewer->parentWidget())) { bool isFullScreen = (fsWidget->windowState() & Qt::WindowFullScreen) != 0; action = commandManager->createAction(V_ShowHideFullScreen, this, !isFullScreen); addAction(action); ret = ret && parent->connect(action, SIGNAL(triggered()), fsWidget, SLOT(toggleFullScreen())); } // swap compared if (parent->canSwapCompared()) { action = addAction(tr("Swap Compared Images")); ret = ret && parent->connect(action, SIGNAL(triggered()), SLOT(swapCompared())); } // reset action = commandManager->createAction(V_ZoomReset, this); addAction(action); ret = ret && parent->connect(action, SIGNAL(triggered()), SLOT(resetSceneViewer())); if (!isEditingLevel) { // fit camera action = commandManager->createAction(V_ZoomFit, this); addAction(action); ret = ret && parent->connect(action, SIGNAL(triggered()), SLOT(fitToCamera())); } // actual pixel size action = commandManager->createAction(V_ActualPixelSize, this); addAction(action); ret = ret && parent->connect(action, SIGNAL(triggered()), SLOT(setActualPixelSize())); // onion skin if (Preferences::instance()->isOnionSkinEnabled() && !parent->isPreviewEnabled()) OnioniSkinMaskGUI::addOnionSkinCommand(this); // preview if (parent->isPreviewEnabled()) { addSeparator(); // save previewed frames action = addAction(tr("Save Previewed Frames")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_SavePreviewedFrames))); ret = ret && parent->connect(action, SIGNAL(triggered()), this, SLOT(savePreviewedFrames())); // regenerate preview action = addAction(tr("Regenerate Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_RegeneratePreview))); ret = ret && parent->connect(action, SIGNAL(triggered()), SLOT(regeneratePreview())); // regenerate frame preview action = addAction(tr("Regenerate Frame Preview")); action->setShortcut(QKeySequence( CommandManager::instance()->getKeyFromId(MI_RegenerateFramePr))); ret = ret && parent->connect(action, SIGNAL(triggered()), SLOT(regeneratePreviewFrame())); } assert(ret); }