From 1c126afd2cc012fc7502009d014e3f747f74b6f4 Mon Sep 17 00:00:00 2001 From: Jeremy Bullock Date: Mon, 17 Aug 2020 23:54:39 -0600 Subject: [PATCH] Add Capturing 2s, 3s etc to Stop Motion (#121) --- stuff/profiles/project_folders.txt | 1 + toonz/sources/include/toonz/tproject.h | 1 + toonz/sources/stopmotion/canon.cpp | 2 +- toonz/sources/stopmotion/stopmotion.cpp | 46 +++++++++++-------- toonz/sources/stopmotion/stopmotion.h | 6 ++- .../stopmotion/stopmotioncontroller.cpp | 35 ++++++++++++-- .../sources/stopmotion/stopmotioncontroller.h | 4 +- toonz/sources/toonzlib/tproject.cpp | 5 +- 8 files changed, 71 insertions(+), 29 deletions(-) diff --git a/stuff/profiles/project_folders.txt b/stuff/profiles/project_folders.txt index 322172f0..f2170ecb 100644 --- a/stuff/profiles/project_folders.txt +++ b/stuff/profiles/project_folders.txt @@ -4,3 +4,4 @@ scenes extras outputs palettes +stopmotion diff --git a/toonz/sources/include/toonz/tproject.h b/toonz/sources/include/toonz/tproject.h index 0d437368..b6b0c2ee 100644 --- a/toonz/sources/include/toonz/tproject.h +++ b/toonz/sources/include/toonz/tproject.h @@ -36,6 +36,7 @@ public: static const std::string Outputs; static const std::string Scripts; static const std::string Palettes; + static const std::string StopMotion; static const TFilePath SandboxProjectName; diff --git a/toonz/sources/stopmotion/canon.cpp b/toonz/sources/stopmotion/canon.cpp index bee1f4ae..e99dc620 100644 --- a/toonz/sources/stopmotion/canon.cpp +++ b/toonz/sources/stopmotion/canon.cpp @@ -847,7 +847,7 @@ bool Canon::downloadImage(EdsBaseRef object) { jpgStream = NULL; if (object) EdsRelease(object); return err; - StopMotion::instance()->m_tempRaw = TApp::instance()->getCurrentScene()->getScene()->decodeFilePath(TFilePath("+extras")).getQString(); + StopMotion::instance()->m_tempRaw = TApp::instance()->getCurrentScene()->getScene()->decodeFilePath(TFilePath("+stopmotion")).getQString(); } diff --git a/toonz/sources/stopmotion/stopmotion.cpp b/toonz/sources/stopmotion/stopmotion.cpp index 08f8ffe8..9671ff73 100644 --- a/toonz/sources/stopmotion/stopmotion.cpp +++ b/toonz/sources/stopmotion/stopmotion.cpp @@ -257,9 +257,9 @@ StopMotion::StopMotion() { ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene(); setToNextNewLevel(); - m_filePath = scene->getDefaultLevelPath(OVL_TYPE, m_levelName.toStdWString()) - .getParentDir() - .getQString(); + //m_filePath = scene->getDefaultLevelPath(OVL_TYPE, m_levelName.toStdWString()) + // .getParentDir() + // .getQString(); } //----------------------------------------------------------------- @@ -1006,6 +1006,13 @@ void StopMotion::setXSheetFrameNumber(int frameNumber) { //----------------------------------------------------------------- +void StopMotion::setCaptureNumberOfFrames(int frames) { + m_captureNumberOfFrames = frames; + emit(captureNumberOfFramesChanged(frames)); +} + +//----------------------------------------------------------------- + bool StopMotion::loadLineUpImage() { if (m_liveViewStatus == LiveViewClosed || m_userCalledPause) return false; int row; @@ -1635,18 +1642,16 @@ bool StopMotion::importImage() { col += 1; xsh->insertColumn(col); } - xsh->insertCells(row, col); - xsh->setCell(row, col, TXshCell(sl, fid)); + for (int i = 0; i < m_captureNumberOfFrames; i++) { + xsh->insertCells(row + i, col); + xsh->setCell(row + i, col, TXshCell(sl, fid)); + } app->getCurrentColumn()->setColumnIndex(col); if (getReviewTime() == 0 || m_isTimeLapse) - app->getCurrentFrame()->setFrame(row + 1); - m_xSheetFrameNumber = row + 2; + app->getCurrentFrame()->setFrame(row + m_captureNumberOfFrames); + m_xSheetFrameNumber = row + 1 + m_captureNumberOfFrames; emit(xSheetFrameNumberChanged(m_xSheetFrameNumber)); postImportProcess(); - // if (m_newImage->getLx() > 2000) { - // m_subsampling = 4; - // setSubsampling(); - //} return true; } @@ -1683,13 +1688,14 @@ bool StopMotion::importImage() { // if there is a column containing the same level if (foundRow >= 0) { - // put the cell at the bottom - xsh->insertCells(row, foundCol); - xsh->setCell(row, foundCol, TXshCell(sl, fid)); + for (int i = 0; i < m_captureNumberOfFrames; i++) { + xsh->insertCells(row + i, foundCol); + xsh->setCell(row + i, foundCol, TXshCell(sl, fid)); + } app->getCurrentColumn()->setColumnIndex(foundCol); if (getReviewTime() == 0 || m_isTimeLapse) - app->getCurrentFrame()->setFrame(row + 1); - m_xSheetFrameNumber = row + 2; + app->getCurrentFrame()->setFrame(row + m_captureNumberOfFrames); + m_xSheetFrameNumber = row + 1 + m_captureNumberOfFrames; emit(xSheetFrameNumberChanged(m_xSheetFrameNumber)); } // if the level is registered in the scene, but is not placed in the xsheet, @@ -1699,11 +1705,13 @@ bool StopMotion::importImage() { col += 1; xsh->insertColumn(col); } - xsh->setCell(row, col, TXshCell(sl, fid)); + for (int i = 0; i < m_captureNumberOfFrames; i++) { + xsh->setCell(row + i, col, TXshCell(sl, fid)); + } app->getCurrentColumn()->setColumnIndex(col); if (getReviewTime() == 0 || m_isTimeLapse) - app->getCurrentFrame()->setFrame(row + 1); - m_xSheetFrameNumber = row + 2; + app->getCurrentFrame()->setFrame(row + m_captureNumberOfFrames); + m_xSheetFrameNumber = row + 1 + m_captureNumberOfFrames; emit(xSheetFrameNumberChanged(m_xSheetFrameNumber)); } postImportProcess(); diff --git a/toonz/sources/stopmotion/stopmotion.h b/toonz/sources/stopmotion/stopmotion.h index c65d55f4..39a928f4 100644 --- a/toonz/sources/stopmotion/stopmotion.h +++ b/toonz/sources/stopmotion/stopmotion.h @@ -51,9 +51,10 @@ private: // file stuff int m_frameNumber = 1; int m_xSheetFrameNumber = 1; + int m_captureNumberOfFrames = 1; QString m_levelName = ""; QString m_fileType = "jpg"; - QString m_filePath = "+extras"; + QString m_filePath = "+stopmotion"; QString m_frameInfoText = ""; QString m_infoColorName = ""; QString m_frameInfoToolTip = ""; @@ -114,6 +115,8 @@ public: // files and frames void setXSheetFrameNumber(int frameNumber); int getXSheetFrameNumber() { return m_xSheetFrameNumber; } + void setCaptureNumberOfFrames(int frames); + int getCaptureNumberOfFrames() { return m_captureNumberOfFrames; } void setFrameNumber(int frameNumber); int getFrameNumber() { return m_frameNumber; } void setLevelName(QString levelName); @@ -236,6 +239,7 @@ signals: void frameNumberChanged(int); void frameInfoTextChanged(QString); void xSheetFrameNumberChanged(int); + void captureNumberOfFramesChanged(int); // options void optionsChanged(); diff --git a/toonz/sources/stopmotion/stopmotioncontroller.cpp b/toonz/sources/stopmotion/stopmotioncontroller.cpp index bc1c8c4f..606f5ee0 100644 --- a/toonz/sources/stopmotion/stopmotioncontroller.cpp +++ b/toonz/sources/stopmotion/stopmotioncontroller.cpp @@ -233,6 +233,10 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) { m_previousXSheetFrameButton = new QToolButton(this); m_onionOpacityFld = new DVGui::IntField(this); + m_captureFramesCombo = new QComboBox(this); + m_captureFramesCombo->addItems({ "1s", "2s", "3s", "4s", "5s", "6s", "7s", "8s" }); + m_captureFramesCombo->setCurrentIndex(m_stopMotion->getCaptureNumberOfFrames() - 1); + // should choosing the file type is disabled for simplicty // too many options can be a bad thing m_fileTypeCombo = new QComboBox(this); @@ -412,10 +416,12 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) { fileTypeLay->setMargin(0); fileTypeLay->setSpacing(3); { - fileTypeLay->addWidget(new QLabel(tr("File Type:"), this), 0); + //fileTypeLay->addWidget(new QLabel(tr("File Type:"), this), 0); fileTypeLay->addWidget(m_fileTypeCombo, 1); - fileTypeLay->addSpacing(10); + //fileTypeLay->addSpacing(10); fileTypeLay->addWidget(m_fileFormatOptionButton); + m_fileTypeCombo->hide(); + m_fileFormatOptionButton->hide(); } fileLay->addLayout(fileTypeLay, 0); @@ -423,8 +429,9 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) { saveInLay->setMargin(0); saveInLay->setSpacing(3); { - saveInLay->addWidget(new QLabel(tr("Save In:"), this), 0); + //saveInLay->addWidget(new QLabel(tr("Save In:"), this), 0); saveInLay->addWidget(m_saveInFileFld, 1); + m_saveInFileFld->hide(); } fileLay->addLayout(saveInLay, 0); // fileLay->addWidget(subfolderButton, 0); @@ -437,7 +444,9 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) { displayLay->setHorizontalSpacing(3); displayLay->setVerticalSpacing(5); { - displayLay->addWidget(new QLabel(tr("XSheet Frame:"), this), 0, 0, + displayLay->addWidget(new QLabel(tr("Expose as: ")), 0, 0, Qt::AlignRight); + displayLay->addWidget(m_captureFramesCombo, 0, 1, Qt::AlignLeft); + displayLay->addWidget(new QLabel(tr("XSheet Frame:"), this), 1, 0, Qt::AlignRight); QHBoxLayout *xsheetLay = new QHBoxLayout(); xsheetLay->setMargin(0); @@ -450,7 +459,7 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) { Qt::AlignCenter); xsheetLay->addStretch(50); } - displayLay->addLayout(xsheetLay, 0, 1); + displayLay->addLayout(xsheetLay, 1, 1); } displayLay->setColumnStretch(0, 0); displayLay->setColumnStretch(1, 1); @@ -1036,6 +1045,10 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) { SLOT(onPreviousXSheetFrame())); ret = ret && connect(m_setToCurrentXSheetFrameButton, SIGNAL(clicked()), this, SLOT(setToCurrentXSheetFrame())); + ret = ret && connect(m_captureFramesCombo, SIGNAL(currentIndexChanged(int)), + this, SLOT(onCaptureFramesChanged(int))); + ret = ret && connect(m_stopMotion, SIGNAL(captureNumberOfFramesChanged(int)), + this, SLOT(onCaptureNumberOfFramesChanged(int))); ret = ret && connect(m_onionOpacityFld, SIGNAL(valueEditedByHand()), this, SLOT(onOnionOpacityFldEdited())); ret = ret && connect(m_onionOpacityFld, SIGNAL(valueChanged(bool)), this, @@ -1670,6 +1683,12 @@ void StopMotionController::onXSheetFrameNumberChanged(int frameNumber) { //----------------------------------------------------------------------------- +void StopMotionController::onCaptureNumberOfFramesChanged(int frames) { + m_captureFramesCombo->setCurrentIndex(frames - 1); +} + +//----------------------------------------------------------------------------- + void StopMotionController::onFilePathChanged(QString filePath) { m_saveInFileFld->setPath(filePath); } @@ -2921,6 +2940,12 @@ void StopMotionController::onXSheetFrameNumberChanged() { //----------------------------------------------------------------------------- +void StopMotionController::onCaptureFramesChanged(int index) { + m_stopMotion->setCaptureNumberOfFrames(index + 1); +} + +//----------------------------------------------------------------------------- + void StopMotionController::onSaveInPathEdited() { m_stopMotion->setFilePath(m_saveInFileFld->getPath()); } diff --git a/toonz/sources/stopmotion/stopmotioncontroller.h b/toonz/sources/stopmotion/stopmotioncontroller.h index 34fd6b43..faec8b37 100644 --- a/toonz/sources/stopmotion/stopmotioncontroller.h +++ b/toonz/sources/stopmotion/stopmotioncontroller.h @@ -96,7 +96,7 @@ class StopMotionController final : public QWidget { *m_liveViewCompensationSlider; QComboBox *m_cameraListCombo, *m_exposureCombo, *m_fileTypeCombo, *m_whiteBalanceCombo, *m_resolutionCombo, *m_imageQualityCombo, - *m_pictureStyleCombo, *m_controlDeviceCombo; + *m_pictureStyleCombo, *m_controlDeviceCombo, *m_captureFramesCombo; LevelNameLineEdit *m_levelNameEdit; QCheckBox *m_blackScreenForCapture, *m_placeOnXSheetCB, *m_directShowCB, *m_liveViewOnAllFramesCB, *m_useMjpgCB, *m_useNumpadCB, *m_drawBeneathCB, @@ -157,6 +157,8 @@ protected slots: void onFileTypeActivated(); void onFrameNumberChanged(); void onXSheetFrameNumberChanged(); + void onCaptureFramesChanged(int index); + void onCaptureNumberOfFramesChanged(int frames); void onFrameCaptured(QImage &image); void onOnionOpacityFldEdited(); void onOnionOpacitySliderChanged(bool ignore); diff --git a/toonz/sources/toonzlib/tproject.cpp b/toonz/sources/toonzlib/tproject.cpp index e3bb018a..e2ba1014 100644 --- a/toonz/sources/toonzlib/tproject.cpp +++ b/toonz/sources/toonzlib/tproject.cpp @@ -54,7 +54,8 @@ const std::string /*! Default outputs folder: is used to save all rendered scenes.*/ TProject::Outputs = "outputs", /*! Default palettes folder: is used for color design (色指定)*/ - TProject::Palettes = "palettes"; + TProject::Palettes = "palettes", + TProject::StopMotion = "stopmotion"; //! Default project name const TFilePath TProject::SandboxProjectName("sandbox"); @@ -944,7 +945,7 @@ void TProjectManager::getFolderNames(std::vector &names) { } const std::string stdNames[] = {TProject::Inputs, TProject::Drawings, TProject::Scenes, TProject::Extras, - TProject::Outputs, TProject::Scripts}; + TProject::Outputs, TProject::Scripts, TProject::StopMotion}; for (auto const &name : stdNames) { // se il nome non e' gia' stato inserito lo aggiungo if (std::find(names.begin(), names.end(), name) == names.end())