Remove Camera Capture Popup Window (#378)

* Remove Camera Capture Popup

* clang
This commit is contained in:
Jeremy Bullock 2020-11-04 12:14:28 -07:00 committed by GitHub
parent 60c9cb33d2
commit a922f46562
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 937 additions and 6829 deletions

View file

@ -1437,13 +1437,6 @@ ParamsPage {
/* -----------------------------------------------------------------------------
Misc
----------------------------------------------------------------------------- */
PencilTestPopup {
min-height: 730px;
/* Allow for using a 768 screen */
min-width: 512px;
/* some clipping will still occur on width, but this
allows for filling half of a 1024 screen */
}
#MatchLineButton {
background-color: #565656;
}
@ -1693,7 +1686,7 @@ ProjectPopup QLabel {
color: #9fdaff;
}
/* -----------------------------------------------------------------------------
PencilTestPopup / CameraCapture Window
CameraCapture Window
----------------------------------------------------------------------------- */
#GearButton::menu-indicator {
image: url("");

View file

@ -1437,13 +1437,6 @@ ParamsPage {
/* -----------------------------------------------------------------------------
Misc
----------------------------------------------------------------------------- */
PencilTestPopup {
min-height: 730px;
/* Allow for using a 768 screen */
min-width: 512px;
/* some clipping will still occur on width, but this
allows for filling half of a 1024 screen */
}
#MatchLineButton {
background-color: #464646;
}
@ -1693,7 +1686,7 @@ ProjectPopup QLabel {
color: #9fdaff;
}
/* -----------------------------------------------------------------------------
PencilTestPopup / CameraCapture Window
CameraCapture Window
----------------------------------------------------------------------------- */
#GearButton::menu-indicator {
image: url("");

View file

@ -1437,13 +1437,6 @@ ParamsPage {
/* -----------------------------------------------------------------------------
Misc
----------------------------------------------------------------------------- */
PencilTestPopup {
min-height: 730px;
/* Allow for using a 768 screen */
min-width: 512px;
/* some clipping will still occur on width, but this
allows for filling half of a 1024 screen */
}
#MatchLineButton {
background-color: #ffffff;
}
@ -1693,7 +1686,7 @@ ProjectPopup QLabel {
color: #000000;
}
/* -----------------------------------------------------------------------------
PencilTestPopup / CameraCapture Window
CameraCapture Window
----------------------------------------------------------------------------- */
#GearButton::menu-indicator {
image: url("");

View file

@ -1437,13 +1437,6 @@ ParamsPage {
/* -----------------------------------------------------------------------------
Misc
----------------------------------------------------------------------------- */
PencilTestPopup {
min-height: 730px;
/* Allow for using a 768 screen */
min-width: 512px;
/* some clipping will still occur on width, but this
allows for filling half of a 1024 screen */
}
#MatchLineButton {
background-color: #6e6e6e;
}
@ -1693,7 +1686,7 @@ ProjectPopup QLabel {
color: #9fdaff;
}
/* -----------------------------------------------------------------------------
PencilTestPopup / CameraCapture Window
CameraCapture Window
----------------------------------------------------------------------------- */
#GearButton::menu-indicator {
image: url("");

View file

@ -2,12 +2,6 @@
Misc
----------------------------------------------------------------------------- */
PencilTestPopup {
min-height: 730px; /* Allow for using a 768 screen */
min-width: 512px; /* some clipping will still occur on width, but this
allows for filling half of a 1024 screen */
}
// #HistoryPanel {}
#MatchLineButton {

View file

@ -88,11 +88,9 @@ ProjectPopup {
}
/* -----------------------------------------------------------------------------
PencilTestPopup / CameraCapture Window
CameraCapture Window
----------------------------------------------------------------------------- */
//PencilTestPopup {}
#GearButton {
&::menu-indicator{
image: url("");

View file

@ -1437,13 +1437,6 @@ ParamsPage {
/* -----------------------------------------------------------------------------
Misc
----------------------------------------------------------------------------- */
PencilTestPopup {
min-height: 730px;
/* Allow for using a 768 screen */
min-width: 512px;
/* some clipping will still occur on width, but this
allows for filling half of a 1024 screen */
}
#MatchLineButton {
background-color: #a6a6a6;
}
@ -1693,7 +1686,7 @@ ProjectPopup QLabel {
color: #000000;
}
/* -----------------------------------------------------------------------------
PencilTestPopup / CameraCapture Window
CameraCapture Window
----------------------------------------------------------------------------- */
#GearButton::menu-indicator {
image: url("");

View file

@ -253,7 +253,6 @@ MI_PasteNumbers=
MI_PasteValues=
MI_Pause=
MI_PCheck=
MI_PencilTest=
MI_PickStyleAreas=
MI_PickStyleLines=
MI_Play=P

View file

@ -253,7 +253,6 @@ MI_PasteNumbers=
MI_PasteValues=
MI_Pause=
MI_PCheck=
MI_PencilTest=
MI_PickStyleAreas=
MI_PickStyleLines=
MI_Play=Return

View file

@ -253,7 +253,6 @@ MI_PasteNumbers=
MI_PasteValues=
MI_Pause=
MI_PCheck=
MI_PencilTest=
MI_PickStyleAreas=
MI_PickStyleLines=
MI_Play=Ctrl+Return

View file

@ -253,7 +253,6 @@ MI_PasteNumbers=
MI_PasteValues=
MI_Pause=
MI_PCheck=
MI_PencilTest=
MI_PickStyleAreas=
MI_PickStyleLines=
MI_Play=Return

View file

@ -6,7 +6,6 @@
#include "tenv.h"
#include "tsystem.h"
#include "filebrowsermodel.h"
#include "penciltestpopup.h"
#include "tlevel_io.h"
#include "toutputproperties.h"
#include "filebrowserpopup.h"
@ -195,6 +194,46 @@ bool getRasterLevelSize(TXshLevel *level, TDimension &dim) {
}; // namespace
//=============================================================================
std::wstring FlexibleNameCreator::getPrevious() {
if (m_s.empty() || (m_s[0] == 0 && m_s.size() == 1)) {
m_s.push_back('Z' - 'A');
m_s.push_back('Z' - 'A');
return L"ZZ";
}
int i = 0;
int n = m_s.size();
while (i < n) {
m_s[i]--;
if (m_s[i] >= 0) break;
m_s[i] = 'Z' - 'A';
i++;
}
if (i >= n) {
n--;
m_s.pop_back();
}
std::wstring s;
for (i = n - 1; i >= 0; i--) s.append(1, (wchar_t)(L'A' + m_s[i]));
return s;
}
//-------------------------------------------------------------------
bool FlexibleNameCreator::setCurrent(std::wstring name) {
if (name.empty() || name.size() > 2) return false;
std::vector<int> newNameBuf;
for (std::wstring::iterator it = name.begin(); it != name.end(); ++it) {
int s = (int)((*it) - L'A');
if (s < 0 || s > 'Z' - 'A') return false;
newNameBuf.push_back(s);
}
m_s.clear();
for (int i = newNameBuf.size() - 1; i >= 0; i--) m_s.push_back(newNameBuf[i]);
return true;
}
//-----------------------------------------------------------------------------
StopMotion::StopMotion() {
@ -257,7 +296,8 @@ StopMotion::StopMotion() {
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
setToNextNewLevel();
//m_filePath = scene->getDefaultLevelPath(OVL_TYPE, m_levelName.toStdWString())
// m_filePath = scene->getDefaultLevelPath(OVL_TYPE,
// m_levelName.toStdWString())
// .getParentDir()
// .getQString();
}
@ -1007,8 +1047,8 @@ void StopMotion::setXSheetFrameNumber(int frameNumber) {
//-----------------------------------------------------------------
void StopMotion::setCaptureNumberOfFrames(int frames) {
m_captureNumberOfFrames = frames;
emit(captureNumberOfFramesChanged(frames));
m_captureNumberOfFrames = frames;
emit(captureNumberOfFramesChanged(frames));
}
//-----------------------------------------------------------------
@ -1440,15 +1480,15 @@ bool StopMotion::importImage() {
scene->decodeFilePath(fullResFolder + TFilePath(levelName + L"..jpg"));
TFilePath fullResFile(fullResFp.withFrame(frameNumber));
TFilePath fullResRawFile(fullResFile.getQString().replace(fullResFile.getQString().lastIndexOf("jpg"), 3, "cr2"));
TFilePath fullResRawFile(fullResFile.getQString().replace(
fullResFile.getQString().lastIndexOf("jpg"), 3, "cr2"));
m_tempRaw = fullResRawFile.getQString();
TFilePath liveViewFp =
scene->decodeFilePath(liveViewFolder + TFilePath(levelName + L"..jpg"));
TFilePath liveViewFile(liveViewFp.withFrame(frameNumber));
TFilePath tempFile = parentDir + "temp.jpg";
TFilePath tempRaw = parentDir + "temp.cr2";
TFilePath tempRaw = parentDir + "temp.cr2";
TXshSimpleLevel *sl = 0;
TXshLevel *level = scene->getLevelSet()->getLevel(levelName);
@ -1581,10 +1621,9 @@ bool StopMotion::importImage() {
TSystem::deleteFile(tempFile);
if (TSystem::doesExistFileOrLevel(TFilePath(tempRaw))) {
TSystem::copyFile(fullResRawFile, tempRaw);
TSystem::deleteFile(tempRaw);
TSystem::copyFile(fullResRawFile, tempRaw);
TSystem::deleteFile(tempRaw);
}
if (m_hasLineUpImage) {
JpgConverter::saveJpg(m_lineUpImage, liveViewFile);
@ -1643,8 +1682,8 @@ bool StopMotion::importImage() {
xsh->insertColumn(col);
}
for (int i = 0; i < m_captureNumberOfFrames; i++) {
xsh->insertCells(row + i, col);
xsh->setCell(row + i, col, TXshCell(sl, fid));
xsh->insertCells(row + i, col);
xsh->setCell(row + i, col, TXshCell(sl, fid));
}
app->getCurrentColumn()->setColumnIndex(col);
if (getReviewTime() == 0 || m_isTimeLapse)
@ -1689,8 +1728,8 @@ bool StopMotion::importImage() {
// if there is a column containing the same level
if (foundRow >= 0) {
for (int i = 0; i < m_captureNumberOfFrames; i++) {
xsh->insertCells(row + i, foundCol);
xsh->setCell(row + i, foundCol, TXshCell(sl, fid));
xsh->insertCells(row + i, foundCol);
xsh->setCell(row + i, foundCol, TXshCell(sl, fid));
}
app->getCurrentColumn()->setColumnIndex(foundCol);
if (getReviewTime() == 0 || m_isTimeLapse)
@ -1706,7 +1745,7 @@ bool StopMotion::importImage() {
xsh->insertColumn(col);
}
for (int i = 0; i < m_captureNumberOfFrames; i++) {
xsh->setCell(row + i, col, TXshCell(sl, fid));
xsh->setCell(row + i, col, TXshCell(sl, fid));
}
app->getCurrentColumn()->setColumnIndex(col);
if (getReviewTime() == 0 || m_isTimeLapse)
@ -1824,13 +1863,13 @@ void StopMotion::captureDslrImage() {
TFilePath parentDir = scene->decodeFilePath(TFilePath(m_filePath));
TFilePath tempFile = parentDir + "temp.jpg";
TFilePath tempRaw = parentDir + "temp.cr2";
TFilePath tempRaw = parentDir + "temp.cr2";
if (!TFileStatus(parentDir).doesExist()) {
TSystem::mkDir(parentDir);
}
m_tempFile = tempFile.getQString();
m_tempRaw = tempRaw.getQString();
m_tempRaw = tempRaw.getQString();
#ifdef WITH_CANON
m_canon->takePicture();
@ -1900,13 +1939,13 @@ void StopMotion::takeTestShot() {
ToonzScene *scene = app->getCurrentScene()->getScene();
TFilePath parentDir = scene->decodeFilePath(TFilePath(m_filePath));
TFilePath tempFile = parentDir + "temp.jpg";
TFilePath tempRaw = parentDir + "temp.cr2";
TFilePath tempRaw = parentDir + "temp.cr2";
if (!TFileStatus(parentDir).doesExist()) {
TSystem::mkDir(parentDir);
}
m_tempFile = tempFile.getQString();
m_tempRaw = tempRaw.getQString();
m_tempRaw = tempRaw.getQString();
m_light->showOverlays();
m_canon->takePicture();
}
@ -2000,18 +2039,19 @@ void StopMotion::saveTestShot() {
TFilePath(levelName + L"+" + QString::number(fileNumber).toStdWString() +
L".jpg"));
TFilePath fullResRawFile(testsThumbsFile.getQString().replace(testsThumbsFile.getQString().lastIndexOf("jpg"), 3, "cr2"));
TFilePath fullResRawFile(testsThumbsFile.getQString().replace(
testsThumbsFile.getQString().lastIndexOf("jpg"), 3, "cr2"));
m_tempRaw = fullResRawFile.getQString();
TFilePath tempFile = parentDir + "temp.jpg";
TFilePath tempRaw = parentDir + "temp.cr2";
TFilePath tempRaw = parentDir + "temp.cr2";
if (!m_usingWebcam) {
TSystem::copyFile(testsFile, tempFile);
TSystem::deleteFile(tempFile);
if (TSystem::doesExistFileOrLevel(TFilePath(tempRaw))) {
TSystem::copyFile(fullResRawFile, tempRaw);
TSystem::deleteFile(tempRaw);
TSystem::copyFile(fullResRawFile, tempRaw);
TSystem::deleteFile(tempRaw);
}
} else {
JpgConverter::saveJpg(m_newImage, testsFile);
@ -2489,14 +2529,16 @@ bool StopMotion::exportImageSequence() {
sourceFile = actualLevelFp.withFrame(cellNumber);
}
TFilePath sourceRawFile(sourceFile.getQString().replace(sourceFile.getQString().lastIndexOf("jpg"), 3, "cr2"));
TFilePath sourceRawFile(sourceFile.getQString().replace(
sourceFile.getQString().lastIndexOf("jpg"), 3, "cr2"));
if (!TFileStatus(sourceFile).doesExist()) {
DVGui::error(tr("Could not find the source file."));
return false;
}
exportFile = exportFilePath.withFrame(exportFrameNumber);
TFilePath exportRawFile(exportFile.getQString().replace(exportFile.getQString().lastIndexOf("jpg"), 3, "cr2"));
TFilePath exportRawFile(exportFile.getQString().replace(
exportFile.getQString().lastIndexOf("jpg"), 3, "cr2"));
if (TFileStatus(exportFile).doesExist()) {
QString question = tr("Overwrite existing files?");
int ret = DVGui::MsgBox(question, QObject::tr("Overwrite"),
@ -2505,7 +2547,7 @@ bool StopMotion::exportImageSequence() {
}
TSystem::copyFile(exportFile, sourceFile);
if (TSystem::doesExistFileOrLevel(sourceRawFile)) {
TSystem::copyFile(exportRawFile, sourceRawFile);
TSystem::copyFile(exportRawFile, sourceRawFile);
}
exportFrameNumber++;
if (!TFileStatus(exportFile).doesExist()) {

View file

@ -24,6 +24,7 @@
#include "stopmotionserial.h"
#include "stopmotionlight.h"
#include "toonz/namebuilder.h"
#include "toonz/txshsimplelevel.h"
#include <QObject>
@ -33,6 +34,20 @@ class QCamera;
class QCameraInfo;
class QTimer;
//=============================================================================
// FlexibleNameCreator
// Inherits NameCreator, added function for obtaining the previous name and
// setting the current name.
class FlexibleNameCreator final : public NameCreator {
public:
FlexibleNameCreator() {}
std::wstring getPrevious();
bool setCurrent(std::wstring name);
};
//=============================================================================
enum ASPECT_RATIO { FOUR_THREE = 0, THREE_TWO, SIXTEEN_NINE, OTHER_RATIO };
class StopMotion : public QObject { // Singleton
@ -49,15 +64,15 @@ private:
~StopMotion();
// file stuff
int m_frameNumber = 1;
int m_xSheetFrameNumber = 1;
int m_frameNumber = 1;
int m_xSheetFrameNumber = 1;
int m_captureNumberOfFrames = 1;
QString m_levelName = "";
QString m_fileType = "jpg";
QString m_filePath = "+stopmotion";
QString m_frameInfoText = "";
QString m_infoColorName = "";
QString m_frameInfoToolTip = "";
QString m_levelName = "";
QString m_fileType = "jpg";
QString m_filePath = "+stopmotion";
QString m_frameInfoText = "";
QString m_infoColorName = "";
QString m_frameInfoToolTip = "";
// options
int m_opacity = 255.0;

View file

@ -1,5 +1,6 @@
#include "stopmotioncontroller.h"
#include "webcam.h"
#include "cameracapturelevelcontrol.h"
// TnzLib includes
#include "toonz/levelset.h"
@ -15,6 +16,7 @@
#include "toonz/txshlevelhandle.h"
#include "toonz/txshsimplelevel.h"
#include "toonz/tstageobjecttree.h"
#include "toonz/tproject.h"
// TnzCore includes
#include "filebrowsermodel.h"
@ -26,6 +28,9 @@
#include "tsystem.h"
#include "tfilepath.h"
#include "flipbook.h"
#include "iocommand.h"
#include "tlevel_io.h"
// TnzQt includes
#include "toonzqt/filefield.h"
#include "toonzqt/intfield.h"
@ -61,6 +66,20 @@
#include <dshow.h>
#endif
// Whether to open save-in popup on launch
TEnv::IntVar CamCapOpenSaveInPopupOnLaunch("CamCapOpenSaveInPopupOnLaunch", 0);
// SaveInFolderPopup settings
TEnv::StringVar CamCapSaveInParentFolder("CamCapSaveInParentFolder", "");
TEnv::IntVar CamCapSaveInPopupSubFolder("CamCapSaveInPopupSubFolder", 0);
TEnv::StringVar CamCapSaveInPopupProject("CamCapSaveInPopupProject", "");
TEnv::StringVar CamCapSaveInPopupEpisode("CamCapSaveInPopupEpisode", "1");
TEnv::StringVar CamCapSaveInPopupSequence("CamCapSaveInPopupSequence", "1");
TEnv::StringVar CamCapSaveInPopupScene("CamCapSaveInPopupScene", "1");
TEnv::IntVar CamCapSaveInPopupAutoSubName("CamCapSaveInPopupAutoSubName", 1);
TEnv::IntVar CamCapSaveInPopupCreateSceneInFolder(
"CamCapSaveInPopupCreateSceneInFolder", 0);
namespace {
//-----------------------------------------------------------------------------
@ -171,8 +190,575 @@ QScrollArea *makeChooserPageWithoutScrollBar(QWidget *chooser) {
return scrollArea;
}
//-----------------------------------------------------------------------------
QChar numToLetter(int letterNum) {
switch (letterNum) {
case 0:
return QChar();
break;
case 1:
return 'A';
break;
case 2:
return 'B';
break;
case 3:
return 'C';
break;
case 4:
return 'D';
break;
case 5:
return 'E';
break;
case 6:
return 'F';
break;
case 7:
return 'G';
break;
case 8:
return 'H';
break;
case 9:
return 'I';
break;
default:
return QChar();
break;
}
}
int letterToNum(QChar appendix) {
if (appendix == QChar('A') || appendix == QChar('a'))
return 1;
else if (appendix == QChar('B') || appendix == QChar('b'))
return 2;
else if (appendix == QChar('C') || appendix == QChar('c'))
return 3;
else if (appendix == QChar('D') || appendix == QChar('d'))
return 4;
else if (appendix == QChar('E') || appendix == QChar('e'))
return 5;
else if (appendix == QChar('F') || appendix == QChar('f'))
return 6;
else if (appendix == QChar('G') || appendix == QChar('g'))
return 7;
else if (appendix == QChar('H') || appendix == QChar('h'))
return 8;
else if (appendix == QChar('I') || appendix == QChar('i'))
return 9;
else
return 0;
}
QString convertToFrameWithLetter(int value, int length = -1) {
QString str;
str.setNum((int)(value / 10));
while (str.length() < length) str.push_front("0");
QChar letter = numToLetter(value % 10);
if (!letter.isNull()) str.append(letter);
return str;
}
} // namespace
//=============================================================================
StopMotionSaveInFolderPopup::StopMotionSaveInFolderPopup(QWidget *parent)
: Dialog(parent, true, false, "PencilTestSaveInFolder") {
setWindowTitle(tr("Create the Destination Subfolder to Save"));
m_parentFolderField = new DVGui::FileField(this);
QPushButton *setAsDefaultBtn = new QPushButton(tr("Set As Default"), this);
setAsDefaultBtn->setToolTip(
tr("Set the current \"Save In\" path as the default."));
m_subFolderCB = new QCheckBox(tr("Create Subfolder"), this);
QFrame *subFolderFrame = new QFrame(this);
QGroupBox *infoGroupBox = new QGroupBox(tr("Infomation"), this);
QGroupBox *subNameGroupBox = new QGroupBox(tr("Subfolder Name"), this);
m_projectField = new QLineEdit(this);
m_episodeField = new QLineEdit(this);
m_sequenceField = new QLineEdit(this);
m_sceneField = new QLineEdit(this);
m_autoSubNameCB = new QCheckBox(tr("Auto Format:"), this);
m_subNameFormatCombo = new QComboBox(this);
m_subFolderNameField = new QLineEdit(this);
QCheckBox *showPopupOnLaunchCB =
new QCheckBox(tr("Show This on Launch of the Camera Capture"), this);
m_createSceneInFolderCB = new QCheckBox(tr("Save Scene in Subfolder"), this);
QPushButton *okBtn = new QPushButton(tr("OK"), this);
QPushButton *cancelBtn = new QPushButton(tr("Cancel"), this);
//---- properties
m_subFolderCB->setChecked(CamCapSaveInPopupSubFolder != 0);
subFolderFrame->setEnabled(CamCapSaveInPopupSubFolder != 0);
// project name
QString prjName = QString::fromStdString(CamCapSaveInPopupProject.getValue());
if (prjName.isEmpty()) {
prjName = TProjectManager::instance()
->getCurrentProject()
->getName()
.getQString();
}
m_projectField->setText(prjName);
m_episodeField->setText(
QString::fromStdString(CamCapSaveInPopupEpisode.getValue()));
m_sequenceField->setText(
QString::fromStdString(CamCapSaveInPopupSequence.getValue()));
m_sceneField->setText(
QString::fromStdString(CamCapSaveInPopupScene.getValue()));
m_autoSubNameCB->setChecked(CamCapSaveInPopupAutoSubName != 0);
m_subNameFormatCombo->setEnabled(CamCapSaveInPopupAutoSubName != 0);
QStringList items;
items << tr("C- + Sequence + Scene") << tr("Sequence + Scene")
<< tr("Episode + Sequence + Scene")
<< tr("Project + Episode + Sequence + Scene");
m_subNameFormatCombo->addItems(items);
m_subNameFormatCombo->setCurrentIndex(CamCapSaveInPopupAutoSubName - 1);
showPopupOnLaunchCB->setChecked(CamCapOpenSaveInPopupOnLaunch != 0);
m_createSceneInFolderCB->setChecked(CamCapSaveInPopupCreateSceneInFolder !=
0);
m_createSceneInFolderCB->setToolTip(
tr("Save the current scene in the subfolder.\nSet the output folder path "
"to the subfolder as well."));
addButtonBarWidget(okBtn, cancelBtn);
//---- layout
m_topLayout->setMargin(10);
m_topLayout->setSpacing(10);
{
QGridLayout *saveInLay = new QGridLayout();
saveInLay->setMargin(0);
saveInLay->setHorizontalSpacing(3);
saveInLay->setVerticalSpacing(0);
{
saveInLay->addWidget(new QLabel(tr("Save In:"), this), 0, 0,
Qt::AlignRight | Qt::AlignVCenter);
saveInLay->addWidget(m_parentFolderField, 0, 1);
saveInLay->addWidget(setAsDefaultBtn, 1, 1);
}
saveInLay->setColumnStretch(0, 0);
saveInLay->setColumnStretch(1, 1);
m_topLayout->addLayout(saveInLay);
m_topLayout->addWidget(m_subFolderCB, 0, Qt::AlignLeft);
QVBoxLayout *subFolderLay = new QVBoxLayout();
subFolderLay->setMargin(0);
subFolderLay->setSpacing(10);
{
QGridLayout *infoLay = new QGridLayout();
infoLay->setMargin(10);
infoLay->setHorizontalSpacing(3);
infoLay->setVerticalSpacing(10);
{
infoLay->addWidget(new QLabel(tr("Project:"), this), 0, 0);
infoLay->addWidget(m_projectField, 0, 1);
infoLay->addWidget(new QLabel(tr("Episode:"), this), 1, 0);
infoLay->addWidget(m_episodeField, 1, 1);
infoLay->addWidget(new QLabel(tr("Sequence:"), this), 2, 0);
infoLay->addWidget(m_sequenceField, 2, 1);
infoLay->addWidget(new QLabel(tr("Scene:"), this), 3, 0);
infoLay->addWidget(m_sceneField, 3, 1);
}
infoLay->setColumnStretch(0, 0);
infoLay->setColumnStretch(1, 1);
infoGroupBox->setLayout(infoLay);
subFolderLay->addWidget(infoGroupBox, 0);
QGridLayout *subNameLay = new QGridLayout();
subNameLay->setMargin(10);
subNameLay->setHorizontalSpacing(3);
subNameLay->setVerticalSpacing(10);
{
subNameLay->addWidget(m_autoSubNameCB, 0, 0);
subNameLay->addWidget(m_subNameFormatCombo, 0, 1);
subNameLay->addWidget(new QLabel(tr("Subfolder Name:"), this), 1, 0);
subNameLay->addWidget(m_subFolderNameField, 1, 1);
}
subNameLay->setColumnStretch(0, 0);
subNameLay->setColumnStretch(1, 1);
subNameGroupBox->setLayout(subNameLay);
subFolderLay->addWidget(subNameGroupBox, 0);
subFolderLay->addWidget(m_createSceneInFolderCB, 0, Qt::AlignLeft);
}
subFolderFrame->setLayout(subFolderLay);
m_topLayout->addWidget(subFolderFrame);
m_topLayout->addWidget(showPopupOnLaunchCB, 0, Qt::AlignLeft);
m_topLayout->addStretch(1);
}
resize(300, 440);
//---- signal-slot connection
bool ret = true;
ret = ret && connect(m_subFolderCB, SIGNAL(clicked(bool)), subFolderFrame,
SLOT(setEnabled(bool)));
ret = ret && connect(m_projectField, SIGNAL(textEdited(const QString &)),
this, SLOT(updateSubFolderName()));
ret = ret && connect(m_episodeField, SIGNAL(textEdited(const QString &)),
this, SLOT(updateSubFolderName()));
ret = ret && connect(m_sequenceField, SIGNAL(textEdited(const QString &)),
this, SLOT(updateSubFolderName()));
ret = ret && connect(m_sceneField, SIGNAL(textEdited(const QString &)), this,
SLOT(updateSubFolderName()));
ret = ret && connect(m_autoSubNameCB, SIGNAL(clicked(bool)), this,
SLOT(onAutoSubNameCBClicked(bool)));
ret = ret && connect(m_subNameFormatCombo, SIGNAL(currentIndexChanged(int)),
this, SLOT(updateSubFolderName()));
ret = ret && connect(showPopupOnLaunchCB, SIGNAL(clicked(bool)), this,
SLOT(onShowPopupOnLaunchCBClicked(bool)));
ret = ret && connect(m_createSceneInFolderCB, SIGNAL(clicked(bool)), this,
SLOT(onCreateSceneInFolderCBClicked(bool)));
ret = ret && connect(setAsDefaultBtn, SIGNAL(pressed()), this,
SLOT(onSetAsDefaultBtnPressed()));
ret = ret && connect(okBtn, SIGNAL(clicked(bool)), this, SLOT(onOkPressed()));
ret = ret && connect(cancelBtn, SIGNAL(clicked(bool)), this, SLOT(reject()));
assert(ret);
updateSubFolderName();
}
//-----------------------------------------------------------------------------
QString StopMotionSaveInFolderPopup::getPath() {
if (!m_subFolderCB->isChecked()) return m_parentFolderField->getPath();
// re-code filepath
TFilePath path(m_parentFolderField->getPath() + "\\" +
m_subFolderNameField->text());
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
if (scene) {
path = scene->decodeFilePath(path);
path = scene->codeFilePath(path);
}
return path.getQString();
}
//-----------------------------------------------------------------------------
QString StopMotionSaveInFolderPopup::getParentPath() {
return m_parentFolderField->getPath();
}
//-----------------------------------------------------------------------------
void StopMotionSaveInFolderPopup::showEvent(QShowEvent *event) {
// Show "Save the scene" check box only when the scene is untitled
bool isUntitled =
TApp::instance()->getCurrentScene()->getScene()->isUntitled();
m_createSceneInFolderCB->setVisible(isUntitled);
}
//-----------------------------------------------------------------------------
namespace {
QString formatString(QString inStr, int charNum) {
if (inStr.isEmpty()) return QString("0").rightJustified(charNum, '0');
QString numStr, postStr;
// find the first non-digit character
int index = inStr.indexOf(QRegExp("[^0-9]"), 0);
if (index == -1) // only digits
numStr = inStr;
else if (index == 0) // only post strings
return inStr;
else { // contains both
numStr = inStr.left(index);
postStr = inStr.right(inStr.length() - index);
}
return numStr.rightJustified(charNum, '0') + postStr;
}
}; // namespace
void StopMotionSaveInFolderPopup::updateSubFolderName() {
if (!m_autoSubNameCB->isChecked()) return;
QString episodeStr = formatString(m_episodeField->text(), 3);
QString sequenceStr = formatString(m_sequenceField->text(), 3);
QString sceneStr = formatString(m_sceneField->text(), 4);
QString str;
switch (m_subNameFormatCombo->currentIndex()) {
case 0: // C- + Sequence + Scene
str = QString("C-%1-%2").arg(sequenceStr).arg(sceneStr);
break;
case 1: // Sequence + Scene
str = QString("%1-%2").arg(sequenceStr).arg(sceneStr);
break;
case 2: // Episode + Sequence + Scene
str = QString("%1-%2-%3").arg(episodeStr).arg(sequenceStr).arg(sceneStr);
break;
case 3: // Project + Episode + Sequence + Scene
str = QString("%1-%2-%3-%4")
.arg(m_projectField->text())
.arg(episodeStr)
.arg(sequenceStr)
.arg(sceneStr);
break;
default:
return;
}
m_subFolderNameField->setText(str);
}
//-----------------------------------------------------------------------------
void StopMotionSaveInFolderPopup::onAutoSubNameCBClicked(bool on) {
m_subNameFormatCombo->setEnabled(on);
updateSubFolderName();
}
//-----------------------------------------------------------------------------
void StopMotionSaveInFolderPopup::onShowPopupOnLaunchCBClicked(bool on) {
CamCapOpenSaveInPopupOnLaunch = (on) ? 1 : 0;
}
//-----------------------------------------------------------------------------
void StopMotionSaveInFolderPopup::onCreateSceneInFolderCBClicked(bool on) {
CamCapSaveInPopupCreateSceneInFolder = (on) ? 1 : 0;
}
//-----------------------------------------------------------------------------
void StopMotionSaveInFolderPopup::onSetAsDefaultBtnPressed() {
CamCapSaveInParentFolder = m_parentFolderField->getPath().toStdString();
}
//-----------------------------------------------------------------------------
void StopMotionSaveInFolderPopup::onOkPressed() {
if (!m_subFolderCB->isChecked()) {
accept();
return;
}
// check the subFolder value
QString subFolderName = m_subFolderNameField->text();
if (subFolderName.isEmpty()) {
DVGui::MsgBox(DVGui::WARNING, tr("Subfolder name should not be empty."));
return;
}
int index = subFolderName.indexOf(QRegExp("[\\]:;|=,\\[\\*\\.\"/\\\\]"), 0);
if (index >= 0) {
DVGui::MsgBox(DVGui::WARNING,
tr("Subfolder name should not contain following "
"characters: * . \" / \\ [ ] : ; | = , "));
return;
}
TFilePath fp(m_parentFolderField->getPath());
fp += TFilePath(subFolderName);
TFilePath actualFp =
TApp::instance()->getCurrentScene()->getScene()->decodeFilePath(fp);
if (QFileInfo::exists(actualFp.getQString())) {
DVGui::MsgBox(DVGui::WARNING,
tr("Folder %1 already exists.").arg(actualFp.getQString()));
return;
}
// save the current properties to env data
CamCapSaveInPopupSubFolder = (m_subFolderCB->isChecked()) ? 1 : 0;
CamCapSaveInPopupProject = m_projectField->text().toStdString();
CamCapSaveInPopupEpisode = m_episodeField->text().toStdString();
CamCapSaveInPopupSequence = m_sequenceField->text().toStdString();
CamCapSaveInPopupScene = m_sceneField->text().toStdString();
CamCapSaveInPopupAutoSubName = (!m_autoSubNameCB->isChecked())
? 0
: m_subNameFormatCombo->currentIndex() + 1;
// create folder
try {
TSystem::mkDir(actualFp);
} catch (...) {
DVGui::MsgBox(DVGui::CRITICAL,
tr("It is not possible to create the %1 folder.")
.arg(toQString(actualFp)));
return;
}
createSceneInFolder();
accept();
}
//-----------------------------------------------------------------------------
void StopMotionSaveInFolderPopup::createSceneInFolder() {
// make sure that the check box is displayed (= the scene is untitled) and is
// checked.
if (m_createSceneInFolderCB->isHidden() ||
!m_createSceneInFolderCB->isChecked())
return;
// just in case
if (!m_subFolderCB->isChecked()) return;
// set the output folder
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
if (!scene) return;
TFilePath fp(getPath().toStdWString());
// for the scene folder mode, output destination must be already set to
// $scenefolder or its subfolder. See TSceneProperties::onInitialize()
if (Preferences::instance()->getPathAliasPriority() !=
Preferences::SceneFolderAlias) {
TOutputProperties *prop = scene->getProperties()->getOutputProperties();
prop->setPath(prop->getPath().withParentDir(fp));
}
// save the scene
TFilePath sceneFp =
scene->decodeFilePath(fp) +
TFilePath(m_subFolderNameField->text().toStdWString()).withType("tnz");
IoCmd::saveScene(sceneFp, 0);
}
//-----------------------------------------------------------------------------
void StopMotionSaveInFolderPopup::updateParentFolder() {
// If the parent folder is saved in the scene, use it
ToonzScene *scene = TApp::instance()->getCurrentScene()->getScene();
QString parentFolder =
scene->getProperties()->cameraCaptureSaveInPath().getQString();
if (parentFolder.isEmpty()) {
// else then, if the user-env stores the parent folder value, use it
parentFolder = QString::fromStdString(CamCapSaveInParentFolder);
// else, use "+extras" project folder
if (parentFolder.isEmpty())
parentFolder =
QString("+%1").arg(QString::fromStdString(TProject::Extras));
}
m_parentFolderField->setPath(parentFolder);
}
//=============================================================================
FrameNumberLineEdit::FrameNumberLineEdit(QWidget *parent, int value)
: LineEdit(parent) {
setFixedWidth(54);
m_intValidator = new QIntValidator(this);
setValue(value);
m_intValidator->setRange(1, 9999);
QRegExp rx("^[0-9]{1,4}[A-Ia-i]?$");
m_regexpValidator = new QRegExpValidator(rx, this);
updateValidator();
}
//-----------------------------------------------------------------------------
void FrameNumberLineEdit::updateValidator() {
if (Preferences::instance()->isShowFrameNumberWithLettersEnabled())
setValidator(m_regexpValidator);
else
setValidator(m_intValidator);
}
//-----------------------------------------------------------------------------
void FrameNumberLineEdit::setValue(int value) {
if (value <= 0)
value = 1;
else if (value > 9999)
value = 9999;
QString str;
if (Preferences::instance()->isShowFrameNumberWithLettersEnabled()) {
str = convertToFrameWithLetter(value, 3);
} else {
str.setNum(value);
while (str.length() < 4) str.push_front("0");
}
setText(str);
setCursorPosition(0);
}
//-----------------------------------------------------------------------------
int FrameNumberLineEdit::getValue() {
if (Preferences::instance()->isShowFrameNumberWithLettersEnabled()) {
QString str = text();
// if no letters added
if (str.at(str.size() - 1).isDigit())
return str.toInt() * 10;
else {
return str.left(str.size() - 1).toInt() * 10 +
letterToNum(str.at(str.size() - 1));
}
} else
return text().toInt();
}
//-----------------------------------------------------------------------------
void FrameNumberLineEdit::focusInEvent(QFocusEvent *e) {
m_textOnFocusIn = text();
}
void FrameNumberLineEdit::focusOutEvent(QFocusEvent *e) {
// if the field is empty, then revert the last input
if (text().isEmpty()) setText(m_textOnFocusIn);
LineEdit::focusOutEvent(e);
}
//=============================================================================
LevelNameLineEdit::LevelNameLineEdit(QWidget *parent)
: QLineEdit(parent), m_textOnFocusIn("") {
// Exclude all character which cannot fit in a filepath (Win).
// Dots are also prohibited since they are internally managed by Toonz.
QRegExp rx("[^\\\\/:?*.\"<>|]+");
setValidator(new QRegExpValidator(rx, this));
setObjectName("LargeSizedText");
connect(this, SIGNAL(editingFinished()), this, SLOT(onEditingFinished()));
}
void LevelNameLineEdit::focusInEvent(QFocusEvent *e) {
m_textOnFocusIn = text();
}
void LevelNameLineEdit::onEditingFinished() {
// if the content is not changed, do nothing.
if (text() == m_textOnFocusIn) return;
emit levelNameEdited();
}
//*****************************************************************************
// StopMotionController implementation
//*****************************************************************************
@ -200,7 +786,7 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
// Make Control Page
// **********************
m_saveInFolderPopup = new PencilTestSaveInFolderPopup(this);
m_saveInFolderPopup = new StopMotionSaveInFolderPopup(this);
m_cameraListCombo = new QComboBox(this);
m_resolutionCombo = new QComboBox(this);
m_resolutionCombo->setFixedWidth(fontMetrics().width("0000 x 0000") + 40);
@ -603,7 +1189,17 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
webcamSettingsLayout->setSpacing(0);
webcamSettingsLayout->setMargin(5);
QHBoxLayout *webcamLabelLayout = new QHBoxLayout();
m_webcamLabel = new QLabel("insert webcam name here", this);
QGroupBox *imageFrame = new QGroupBox(tr("Image adjust"), this);
m_webcamLabel = new QLabel("insert webcam name here", this);
m_colorTypeCombo = new QComboBox(this);
m_camCapLevelControl = new CameraCaptureLevelControl(this);
// m_upsideDownCB = new QCheckBox(tr("Upside down"), this);
// m_upsideDownCB->setChecked(false);
imageFrame->setObjectName("CleanupSettingsFrame");
m_colorTypeCombo->addItems(
{tr("Color"), tr("Grayscale"), tr("Black & White")});
m_colorTypeCombo->setCurrentIndex(0);
webcamLabelLayout->addStretch();
webcamLabelLayout->addWidget(m_webcamLabel);
webcamLabelLayout->addStretch();
@ -697,6 +1293,25 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
Qt::AlignCenter);
}
QGridLayout *imageLay = new QGridLayout();
imageLay->setMargin(8);
imageLay->setHorizontalSpacing(3);
imageLay->setVerticalSpacing(5);
{
imageLay->addWidget(new QLabel(tr("Color type:"), this), 0, 0,
Qt::AlignRight);
imageLay->addWidget(m_colorTypeCombo, 0, 1);
imageLay->addWidget(m_camCapLevelControl, 1, 0, 1, 3);
// imageLay->addWidget(m_upsideDownCB, 2, 0, 1, 3, Qt::AlignLeft);
}
imageLay->setColumnStretch(0, 0);
imageLay->setColumnStretch(1, 0);
imageLay->setColumnStretch(2, 1);
imageFrame->setLayout(imageLay);
webcamGridLay->addWidget(imageFrame, 6, 0, 1, 2);
webcamSettingsLayout->addLayout(webcamGridLay);
webcamSettingsLayout->addStretch();
@ -1252,6 +1867,10 @@ StopMotionController::StopMotionController(QWidget *parent) : QWidget(parent) {
SLOT(onWebcamGainSliderChanged(int)));
ret = ret && connect(m_webcamSaturationSlider, SIGNAL(valueChanged(int)),
this, SLOT(onWebcamSaturationSliderChanged(int)));
ret = ret && connect(m_colorTypeCombo, SIGNAL(currentIndexChanged(int)), this,
SLOT(onColorTypeComboChanged(int)));
ret = ret && connect(m_stopMotion->m_webcam, SIGNAL(updateHistogram(cv::Mat)),
this, SLOT(onUpdateHistogramCalled(cv::Mat)));
// Lighting Connections
ret = ret &&
@ -2154,6 +2773,19 @@ void StopMotionController::onResolutionComboActivated(const QString &itemText) {
m_stopMotion->setWebcamResolution(itemText);
}
//-----------------------------------------------------------------------------
void StopMotionController::onColorTypeComboChanged(int index) {
m_camCapLevelControl->setMode(index != 2);
m_stopMotion->m_webcam->setColorMode(index);
}
//-----------------------------------------------------------------------------
void StopMotionController::onUpdateHistogramCalled(cv::Mat image) {
m_camCapLevelControl->updateHistogram(image);
}
////-----------------------------------------------------------------------------
//
// void StopMotionController::onWebcamFocusFldEdited() {

View file

@ -5,7 +5,8 @@
// TnzCore includes
#include "stopmotion.h"
#include "penciltestpopup.h"
#include "toonzqt/dvdialog.h"
#include "toonzqt/lineedit.h"
// TnzQt includes
#include "toonzqt/tabbar.h"
@ -50,6 +51,102 @@ class QToolBar;
class QTimer;
class QGroupBox;
class QPushButton;
class CameraCaptureLevelControl;
class QRegExpValidator;
class QCheckBox;
class QComboBox;
namespace DVGui {
class FileField;
class IntField;
class IntLineEdit;
} // namespace DVGui
//=============================================================================
// FrameNumberLineEdit
// a special Line Edit which accepts imputting alphabets if the preference
// option
// "Show ABC Appendix to the Frame Number in Xsheet Cell" is active.
//-----------------------------------------------------------------------------
class FrameNumberLineEdit : public DVGui::LineEdit {
Q_OBJECT
/* having two validators and switch them according to the preferences*/
QIntValidator *m_intValidator;
QRegExpValidator *m_regexpValidator;
void updateValidator();
QString m_textOnFocusIn;
public:
FrameNumberLineEdit(QWidget *parent = 0, int value = 1);
~FrameNumberLineEdit() {}
/*! Set text in field to \b value. */
void setValue(int value);
/*! Return an integer with text field value. */
int getValue();
protected:
/*! If focus is lost and current text value is out of range emit signal
\b editingFinished.*/
void focusInEvent(QFocusEvent *) override;
void focusOutEvent(QFocusEvent *) override;
void showEvent(QShowEvent *event) override { updateValidator(); }
};
//=============================================================================
class LevelNameLineEdit : public QLineEdit {
Q_OBJECT
QString m_textOnFocusIn;
public:
LevelNameLineEdit(QWidget *parent = 0);
protected:
void focusInEvent(QFocusEvent *e);
protected slots:
void onEditingFinished();
signals:
void levelNameEdited();
};
//=============================================================================
// PencilTestSaveInFolderPopup
//-----------------------------------------------------------------------------
class StopMotionSaveInFolderPopup : public DVGui::Dialog {
Q_OBJECT
DVGui::FileField *m_parentFolderField;
QLineEdit *m_projectField, *m_episodeField, *m_sequenceField, *m_sceneField,
*m_subFolderNameField;
QCheckBox *m_subFolderCB, *m_autoSubNameCB, *m_createSceneInFolderCB;
QComboBox *m_subNameFormatCombo;
void createSceneInFolder();
public:
StopMotionSaveInFolderPopup(QWidget *parent = 0);
QString getPath();
QString getParentPath();
void updateParentFolder();
protected:
void showEvent(QShowEvent *event);
protected slots:
void updateSubFolderName();
void onAutoSubNameCBClicked(bool);
void onShowPopupOnLaunchCBClicked(bool);
void onCreateSceneInFolderCBClicked(bool);
void onSetAsDefaultBtnPressed();
void onOkPressed();
};
//=============================================================================
// StopMotionController
@ -96,17 +193,20 @@ 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_captureFramesCombo;
*m_pictureStyleCombo, *m_controlDeviceCombo, *m_captureFramesCombo,
*m_colorTypeCombo;
LevelNameLineEdit *m_levelNameEdit;
QCheckBox *m_blackScreenForCapture, *m_placeOnXSheetCB, *m_directShowCB,
*m_liveViewOnAllFramesCB, *m_useMjpgCB, *m_useNumpadCB, *m_drawBeneathCB,
*m_timerCB, *m_showScene1, *m_showScene2, *m_showScene3;
*m_timerCB, *m_showScene1, *m_showScene2,
*m_showScene3; //, *m_upsideDownCB;
CameraCaptureLevelControl *m_camCapLevelControl;
DVGui::FileField *m_saveInFileFld;
DVGui::IntLineEdit *m_xSheetFrameNumberEdit;
FrameNumberLineEdit *m_frameNumberEdit;
DVGui::IntField *m_onionOpacityFld, *m_postCaptureReviewFld,
*m_subsamplingFld;
PencilTestSaveInFolderPopup *m_saveInFolderPopup;
StopMotionSaveInFolderPopup *m_saveInFolderPopup;
DVGui::IntField *m_timerIntervalFld;
DVGui::ColorField *m_screen1ColorFld, *m_screen2ColorFld, *m_screen3ColorFld;
QGroupBox *m_screen1Box;
@ -290,6 +390,8 @@ protected slots:
void onWebcamGainSliderChanged(int value);
void onWebcamSaturationSliderChanged(int value);
void getWebcamStatus();
void onColorTypeComboChanged(int index);
void onUpdateHistogramCalled(cv::Mat img);
void onTakeTestButtonClicked();
void onRefreshTests();

View file

@ -24,6 +24,7 @@ TEnv::IntVar StopMotionUseMjpg("StopMotionUseMjpg", 1);
Webcam::Webcam() {
m_useDirectShow = StopMotionUseDirectShow;
m_useMjpg = StopMotionUseMjpg;
m_lut = cv::Mat(1, 256, CV_8U);
}
//-----------------------------------------------------------------
@ -127,6 +128,24 @@ bool Webcam::getWebcamImage(TRaster32P& tempImage) {
if (!error) {
cv::cvtColor(imgOriginal, imgCorrected, cv::COLOR_BGR2BGRA);
cv::flip(imgCorrected, imgCorrected, 0);
emit updateHistogram(imgCorrected);
bool convertBack = false;
if (m_colorMode != 0) {
cv::cvtColor(imgCorrected, imgCorrected, cv::COLOR_RGB2GRAY);
convertBack = true;
}
// color and grayscale mode
if (m_colorMode != 2)
adjustLevel(imgCorrected);
else
binarize(imgCorrected);
if (convertBack) {
cv::cvtColor(imgCorrected, imgCorrected, cv::COLOR_GRAY2BGRA);
}
int width = m_cvWebcam.get(3);
int height = m_cvWebcam.get(4);
int size = imgCorrected.total() * imgCorrected.elemSize();
@ -180,19 +199,19 @@ void Webcam::refreshWebcamResolutions() {
clearWebcamResolutions();
m_webcamResolutions = getWebcam()->supportedViewfinderResolutions();
if (m_webcamResolutions.size() == 0) {
m_webcamResolutions.push_back(QSize(640,360));
m_webcamResolutions.push_back(QSize(640,480));
m_webcamResolutions.push_back(QSize(800,448));
m_webcamResolutions.push_back(QSize(800,600));
m_webcamResolutions.push_back(QSize(848,480));
m_webcamResolutions.push_back(QSize(864,480));
m_webcamResolutions.push_back(QSize(960,540));
m_webcamResolutions.push_back(QSize(960,720));
m_webcamResolutions.push_back(QSize(1024,576));
m_webcamResolutions.push_back(QSize(1280,720));
m_webcamResolutions.push_back(QSize(1600,896));
m_webcamResolutions.push_back(QSize(1600,900));
m_webcamResolutions.push_back(QSize(1920, 1080));
m_webcamResolutions.push_back(QSize(640, 360));
m_webcamResolutions.push_back(QSize(640, 480));
m_webcamResolutions.push_back(QSize(800, 448));
m_webcamResolutions.push_back(QSize(800, 600));
m_webcamResolutions.push_back(QSize(848, 480));
m_webcamResolutions.push_back(QSize(864, 480));
m_webcamResolutions.push_back(QSize(960, 540));
m_webcamResolutions.push_back(QSize(960, 720));
m_webcamResolutions.push_back(QSize(1024, 576));
m_webcamResolutions.push_back(QSize(1280, 720));
m_webcamResolutions.push_back(QSize(1600, 896));
m_webcamResolutions.push_back(QSize(1600, 900));
m_webcamResolutions.push_back(QSize(1920, 1080));
}
}
@ -430,6 +449,42 @@ void Webcam::openSettingsWindow() {
//-----------------------------------------------------------------
void Webcam::adjustLevel(cv::Mat& image) {
if (m_black == 0 && m_white == 255 && m_gamma == 1.0) return;
cv::LUT(image, m_lut, image);
}
//-----------------------------------------------------------------
void Webcam::binarize(cv::Mat& image) {
cv::threshold(image, image, m_threshold, 255, cv::THRESH_BINARY);
}
//-----------------------------------------------------------------
void Webcam::computeLut() {
const float maxChannelValueF = 255.0f;
float value;
uchar* p = m_lut.data;
for (int i = 0; i < 256; i++) {
if (i <= m_black)
value = 0.0f;
else if (i >= m_white)
value = 1.0f;
else {
value = (float)(i - m_black) / (float)(m_white - m_black);
value = std::pow(value, 1.0f / m_gamma);
}
p[i] = (uchar)std::floor(value * maxChannelValueF);
}
}
//-----------------------------------------------------------------
bool Webcam::translateIndex(int index) {
// We are using Qt to get the camera info and supported resolutions, but
// we are using OpenCV to actually get the images.

View file

@ -77,6 +77,14 @@ public:
void setWebcamSaturationValue(int value);
void openSettingsWindow();
void setLut(cv::Mat lut) { m_lut = lut; }
void setColorMode(int mode) { m_colorMode = mode; }
void setWhite(int white) { m_white = white; }
void setBlack(int black) { m_black = black; }
void setThreshold(int threshold) { m_threshold = threshold; }
void setGamma(double gamma) { m_gamma = gamma; }
void computeLut();
cv::Mat getWebcamImage() { return m_webcamImage; }
private:
// Webcam Properties
@ -92,13 +100,24 @@ private:
int m_webcamWidth = 0;
int m_webcamHeight = 0;
bool m_useMjpg = true;
int m_colorMode = 0;
int m_white = 255;
int m_black = 0;
int m_threshold = 128;
double m_gamma = 1.0;
cv::Mat m_lut;
cv::Mat m_webcamImage;
int m_webcamFocusValue = 0;
bool m_webcamAutofocusStatus = true;
void adjustLevel(cv::Mat& image);
void binarize(cv::Mat& image);
signals:
void useMjpgSignal(bool);
void useDirectShowSignal(bool);
void updateHistogram(cv::Mat);
};
#endif // WEBCAM_H

View file

@ -128,7 +128,6 @@ set(MOC_HEADERS
../stopmotion/stopmotionserial.h
../stopmotion/stopmotionlight.h
cameracapturelevelcontrol.h
penciltestpopup.h
)
set(HEADERS
@ -357,7 +356,6 @@ set(SOURCES
../stopmotion/stopmotionserial.cpp
../stopmotion/stopmotionlight.cpp
cameracapturelevelcontrol.cpp
penciltestpopup.cpp
)
add_translation(toonz ${HEADERS} ${SOURCES})

View file

@ -5,7 +5,7 @@
#include "menubarcommandids.h"
#include "cellselection.h"
#include "columnselection.h"
#include "penciltestpopup.h"
#include "stopmotioncontroller.h"
// TnzQt includes
#include "toonzqt/intfield.h"

View file

@ -2,6 +2,7 @@
#include "toonzqt/intfield.h"
#include "toonzqt/doublefield.h"
#include "stopmotion.h"
#include <QPainter>
#include <QMouseEvent>
@ -175,7 +176,7 @@ void CameraCaptureLevelHistogram::mouseMoveEvent(QMouseEvent* event) {
if (hPos < m_black + 1)
hPos = m_black + 1;
else if (hPos > m_white - 1)
hPos = m_white - 1;
hPos = m_white - 1;
float gamma = hPosToGamma(hPos, m_black, m_white);
if (gamma != m_gamma) {
m_gamma = gamma;
@ -320,8 +321,10 @@ CameraCaptureLevelControl::CameraCaptureLevelControl(QWidget* parent)
//-----------------------------------------------------------------------------
void CameraCaptureLevelControl::onHistogramValueChanged(int itemId) {
StopMotion* sm = StopMotion::instance();
if (itemId == CameraCaptureLevelHistogram::ThresholdSlider) {
m_thresholdFld->setValue(m_histogram->threshold());
sm->m_webcam->setThreshold(m_histogram->threshold());
return;
}
if (itemId == CameraCaptureLevelHistogram::BlackSlider) {
@ -333,7 +336,10 @@ void CameraCaptureLevelControl::onHistogramValueChanged(int itemId) {
} else if (itemId == CameraCaptureLevelHistogram::GammaSlider) {
m_gammaFld->setValue(m_histogram->gamma());
}
computeLut();
sm->m_webcam->setBlack(m_blackFld->getValue());
sm->m_webcam->setWhite(m_whiteFld->getValue());
sm->m_webcam->setGamma(m_histogram->gamma());
sm->m_webcam->computeLut();
}
//-----------------------------------------------------------------------------
@ -359,43 +365,4 @@ void CameraCaptureLevelControl::setMode(bool color_grayscale) {
m_gammaFld->setVisible(color_grayscale);
m_thresholdFld->setVisible(!color_grayscale);
update();
}
//-----------------------------------------------------------------------------
void CameraCaptureLevelControl::adjustLevel(cv::Mat& image) {
int black = m_histogram->black();
int white = m_histogram->white();
float gamma = m_histogram->gamma();
if (black == 0 && white == 255 && gamma == 1.0) return;
cv::LUT(image, m_lut, image);
}
void CameraCaptureLevelControl::binarize(cv::Mat& image) {
cv::threshold(image, image, m_histogram->threshold(), 255, cv::THRESH_BINARY);
}
void CameraCaptureLevelControl::computeLut() {
int black = m_histogram->black();
int white = m_histogram->white();
float gamma = m_histogram->gamma();
const float maxChannelValueF = 255.0f;
float value;
uchar* p = m_lut.data;
for (int i = 0; i < 256; i++) {
if (i <= black)
value = 0.0f;
else if (i >= white)
value = 1.0f;
else {
value = (float)(i - black) / (float)(white - black);
value = std::pow(value, 1.0f / gamma);
}
p[i] = (uchar)std::floor(value * maxChannelValueF);
}
}

View file

@ -78,17 +78,12 @@ class CameraCaptureLevelControl : public QFrame {
DVGui::DoubleLineEdit* m_gammaFld;
cv::Mat m_lut;
void computeLut();
public:
CameraCaptureLevelControl(QWidget* parent = 0);
void updateHistogram(cv::Mat& image) { m_histogram->updateHistogram(image); }
void setMode(bool color_grayscale);
void adjustLevel(cv::Mat& image);
void binarize(cv::Mat& image);
protected slots:
void onHistogramValueChanged(int itemId);
void onFieldChanged();

View file

@ -1950,10 +1950,6 @@ void MainWindow::defineActions() {
menuAct = createMenuScanCleanupAction(MI_Cleanup, tr("&Cleanup"), "");
menuAct->setIcon(createQIcon("cleanup"));
menuAct =
createMenuScanCleanupAction(MI_PencilTest, tr("&Camera Capture..."), "");
menuAct->setIcon(createQIcon("camera_capture"));
menuAct = createMenuLevelAction(MI_AddFrames, tr("&Add Frames..."), "");
menuAct->setIcon(createQIcon("add_cells"));
@ -2352,8 +2348,9 @@ void MainWindow::defineActions() {
createMenuWindowsAction(MI_OpenToolbar, tr("&Toolbar"), "");
createMenuWindowsAction(MI_OpenToolOptionBar, tr("&Tool Option Bar"), "");
createMenuWindowsAction(MI_OpenCommandToolbar, tr("&Command Bar"), "");
createMenuWindowsAction(MI_OpenStopMotionPanel, tr("&Stop Motion Controls"),
"");
menuAct = createMenuWindowsAction(MI_OpenStopMotionPanel,
tr("&Stop Motion Controls"), "");
menuAct->setIcon(createQIcon("camera_capture"));
menuAct = createMenuWindowsAction(MI_OpenLevelView, tr("&Viewer"), "");
menuAct->setIcon(createQIcon("viewer"));

View file

@ -492,8 +492,6 @@ void TopBar::loadMenubar() {
addMenuItem(scanCleanupMenu, MI_CleanupPreview);
addMenuItem(scanCleanupMenu, MI_CameraTest);
addMenuItem(scanCleanupMenu, MI_Cleanup);
scanCleanupMenu->addSeparator();
addMenuItem(scanCleanupMenu, MI_PencilTest);
// Menu' VIEW
QMenu *viewMenu = addMenu(tr("View"), m_menuBar);

View file

@ -411,7 +411,6 @@
#define MI_About "MI_About"
#define MI_StartupPopup "MI_StartupPopup"
#define MI_PencilTest "MI_PencilTest"
#define MI_AudioRecording "MI_AudioRecording"
#define MI_LipSyncPopup "MI_LipSyncPopup"
#define MI_AutoInputCellNumber "MI_AutoInputCellNumber"

File diff suppressed because it is too large Load diff

View file

@ -1,323 +0,0 @@
#pragma once
#ifndef PENCILTESTPOPUP_H
#define PENCILTESTPOPUP_H
#include "toonzqt/dvdialog.h"
#include "toonzqt/lineedit.h"
#include "toonz/namebuilder.h"
#include "opencv2/opencv.hpp"
#include <QAbstractVideoSurface>
#include <QRunnable>
#include <QLineEdit>
// forward decl.
class QCamera;
class QCameraImageCapture;
class QComboBox;
class QSlider;
class QCheckBox;
class QPushButton;
class QVideoFrame;
class QTimer;
class QIntValidator;
class QRegExpValidator;
class QPushButton;
#ifdef MACOSX
class QCameraViewfinder;
#endif
namespace DVGui {
class FileField;
class IntField;
class IntLineEdit;
} // namespace DVGui
class CameraCaptureLevelControl;
//=============================================================================
// MyVideoWidget
//-----------------------------------------------------------------------------
class MyVideoWidget : public QWidget {
Q_OBJECT
QImage m_image;
QImage m_previousImage;
int m_countDownTime;
bool m_showOnionSkin;
int m_onionOpacity;
bool m_upsideDown;
QRect m_subCameraRect;
QRect m_preSubCameraRect;
QPoint m_dragStartPos;
QRect m_targetRect;
QTransform m_S2V_Transform; // surface to video transform
enum SUBHANDLE {
HandleNone,
HandleFrame,
HandleTopLeft,
HandleTopRight,
HandleBottomLeft,
HandleBottomRight,
HandleLeft,
HandleTop,
HandleRight,
HandleBottom
} m_activeSubHandle = HandleNone;
void drawSubCamera(QPainter&);
public:
MyVideoWidget(QWidget* parent = 0);
void setImage(const QImage& image) {
m_image = image;
update();
}
void setShowOnionSkin(bool on) { m_showOnionSkin = on; }
void setOnionOpacity(int value) { m_onionOpacity = value; }
void setPreviousImage(QImage prevImage) { m_previousImage = prevImage; }
void showCountDownTime(int time) {
m_countDownTime = time;
repaint();
}
void setSubCameraSize(QSize size);
QRect subCameraRect() { return m_subCameraRect; }
void computeTransform(QSize imgSize);
protected:
void paintEvent(QPaintEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
protected slots:
void onUpsideDownChecked(bool on) { m_upsideDown = on; }
signals:
void startCamera();
void stopCamera();
void subCameraResized(bool isDragging);
};
//=============================================================================
// FrameNumberLineEdit
// a special Line Edit which accepts imputting alphabets if the preference
// option
// "Show ABC Appendix to the Frame Number in Xsheet Cell" is active.
//-----------------------------------------------------------------------------
class FrameNumberLineEdit : public DVGui::LineEdit {
Q_OBJECT
/* having two validators and switch them according to the preferences*/
QIntValidator* m_intValidator;
QRegExpValidator* m_regexpValidator;
void updateValidator();
QString m_textOnFocusIn;
public:
FrameNumberLineEdit(QWidget* parent = 0, int value = 1);
~FrameNumberLineEdit() {}
/*! Set text in field to \b value. */
void setValue(int value);
/*! Return an integer with text field value. */
int getValue();
protected:
/*! If focus is lost and current text value is out of range emit signal
\b editingFinished.*/
void focusInEvent(QFocusEvent*) override;
void focusOutEvent(QFocusEvent*) override;
void showEvent(QShowEvent* event) override { updateValidator(); }
};
//=============================================================================
class LevelNameLineEdit : public QLineEdit {
Q_OBJECT
QString m_textOnFocusIn;
public:
LevelNameLineEdit(QWidget* parent = 0);
protected:
void focusInEvent(QFocusEvent* e);
protected slots:
void onEditingFinished();
signals:
void levelNameEdited();
};
//=============================================================================
// FlexibleNameCreator
// Inherits NameCreator, added function for obtaining the previous name and
// setting the current name.
class FlexibleNameCreator final : public NameCreator {
public:
FlexibleNameCreator() {}
std::wstring getPrevious();
bool setCurrent(std::wstring name);
};
//=============================================================================
// PencilTestSaveInFolderPopup
//-----------------------------------------------------------------------------
class PencilTestSaveInFolderPopup : public DVGui::Dialog {
Q_OBJECT
DVGui::FileField* m_parentFolderField;
QLineEdit *m_projectField, *m_episodeField, *m_sequenceField, *m_sceneField,
*m_subFolderNameField;
QCheckBox *m_subFolderCB, *m_autoSubNameCB, *m_createSceneInFolderCB;
QComboBox* m_subNameFormatCombo;
void createSceneInFolder();
public:
PencilTestSaveInFolderPopup(QWidget* parent = 0);
QString getPath();
QString getParentPath();
void updateParentFolder();
protected:
void showEvent(QShowEvent* event);
protected slots:
void updateSubFolderName();
void onAutoSubNameCBClicked(bool);
void onShowPopupOnLaunchCBClicked(bool);
void onCreateSceneInFolderCBClicked(bool);
void onSetAsDefaultBtnPressed();
void onOkPressed();
};
//=============================================================================
// PencilTestPopup
//-----------------------------------------------------------------------------
class PencilTestPopup : public DVGui::Dialog {
Q_OBJECT
QTimer* m_timer;
cv::VideoCapture m_cvWebcam;
QSize m_resolution;
//--------
QCamera* m_currentCamera;
QString m_deviceName;
MyVideoWidget* m_videoWidget;
QComboBox *m_cameraListCombo, *m_resolutionCombo, *m_fileTypeCombo,
*m_colorTypeCombo;
LevelNameLineEdit* m_levelNameEdit;
QCheckBox *m_upsideDownCB, *m_onionSkinCB, *m_saveOnCaptureCB, *m_timerCB;
QPushButton *m_fileFormatOptionButton, *m_captureWhiteBGButton,
*m_captureButton, *m_loadImageButton;
DVGui::FileField* m_saveInFileFld;
FrameNumberLineEdit* m_frameNumberEdit;
DVGui::IntField *m_bgReductionFld, *m_onionOpacityFld, *m_timerIntervalFld;
QTimer *m_captureTimer, *m_countdownTimer;
cv::Mat m_whiteBGImg;
// used only for Windows
QPushButton* m_captureFilterSettingsBtn;
PencilTestSaveInFolderPopup* m_saveInFolderPopup;
CameraCaptureLevelControl* m_camCapLevelControl;
QLabel* m_frameInfoLabel;
QToolButton* m_previousLevelButton;
QPushButton* m_subcameraButton;
DVGui::IntLineEdit *m_subWidthFld, *m_subHeightFld;
QSize m_allowedCameraSize;
bool m_captureWhiteBGCue;
bool m_captureCue;
bool m_alwaysOverwrite = false;
bool m_useMjpg;
#ifdef _WIN32
bool m_useDirectShow;
#endif
void processImage(cv::Mat& procImage);
bool importImage(QImage image);
void setToNextNewLevel();
void updateLevelNameAndFrame(std::wstring levelName);
void getWebcamImage();
QMenu* createOptionsMenu();
int translateIndex(int camIndex);
public:
PencilTestPopup();
~PencilTestPopup();
protected:
void showEvent(QShowEvent* event) override;
void hideEvent(QHideEvent* event) override;
void keyPressEvent(QKeyEvent* event) override;
bool event(QEvent* e) override;
protected slots:
void refreshCameraList();
void onCameraListComboActivated(int index);
void onResolutionComboActivated();
void onFileFormatOptionButtonPressed();
void onLevelNameEdited();
void onNextName();
void onPreviousName();
void onColorTypeComboChanged(int index);
void onFrameCaptured(cv::Mat& image);
void onCaptureWhiteBGButtonPressed();
void onOnionCBToggled(bool);
void onLoadImageButtonPressed();
void onOnionOpacityFldEdited();
void onTimerCBToggled(bool);
void onCaptureTimerTimeout();
void onCountDown();
void onCaptureButtonClicked(bool);
void onCaptureFilterSettingsBtnPressed();
void refreshFrameInfo();
void onSaveInPathEdited();
void onSceneSwitched();
void onSubCameraToggled(bool);
void onSubCameraResized(bool isDragging);
void onSubCameraSizeEdited();
void onTimeout();
public slots:
void openSaveInFolderPopup();
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,372 +0,0 @@
#pragma once
#ifndef PENCILTESTPOPUP_H
#define PENCILTESTPOPUP_H
#include "toonzqt/dvdialog.h"
#include "toonzqt/lineedit.h"
#include "toonz/namebuilder.h"
#include <QAbstractVideoSurface>
#include <QRunnable>
// forward decl.
class QCamera;
class QCameraImageCapture;
class QComboBox;
class QLineEdit;
class QSlider;
class QCheckBox;
class QPushButton;
class QVideoFrame;
class QTimer;
class QIntValidator;
class QRegExpValidator;
class QPushButton;
#ifdef MACOSX
class QCameraViewfinder;
#endif
namespace DVGui {
class FileField;
class IntField;
class IntLineEdit;
} // namespace DVGui
class CameraCaptureLevelControl;
class ApplyLutTask : public QRunnable {
protected:
int m_fromY, m_toY;
QImage& m_img;
std::vector<int>& m_lut;
public:
ApplyLutTask(int from, int to, QImage& img, std::vector<int>& lut)
: m_fromY(from), m_toY(to), m_img(img), m_lut(lut) {}
private:
virtual void run() override;
};
class ApplyGrayLutTask : public ApplyLutTask {
public:
ApplyGrayLutTask(int from, int to, QImage& img, std::vector<int>& lut)
: ApplyLutTask(from, to, img, lut) {}
private:
void run() override;
};
//=============================================================================
// MyVideoSurface
//-----------------------------------------------------------------------------
class QVideoSurfaceFormat;
class MyVideoSurface : public QAbstractVideoSurface {
Q_OBJECT
public:
MyVideoSurface(QWidget* widget, QObject* parent = 0);
QList<QVideoFrame::PixelFormat> supportedPixelFormats(
QAbstractVideoBuffer::HandleType handleType =
QAbstractVideoBuffer::NoHandle) const;
bool isFormatSupported(const QVideoSurfaceFormat& format,
QVideoSurfaceFormat* similar) const;
bool start(const QVideoSurfaceFormat& format);
void stop();
bool present(const QVideoFrame& frame);
QRect videoRect() const { return m_targetRect; }
QRect sourceRect() const { return m_sourceRect; }
void updateVideoRect();
QTransform transform() { return m_S2V_Transform; }
private:
QWidget* m_widget;
QImage::Format m_imageFormat;
QRect m_targetRect;
QSize m_imageSize;
QRect m_sourceRect;
QVideoFrame m_currentFrame;
QTransform m_S2V_Transform; // surface to video transform
signals:
void frameCaptured(QImage& image);
};
//=============================================================================
// MyVideoWidget
//-----------------------------------------------------------------------------
class MyVideoWidget : public QWidget {
Q_OBJECT
QImage m_image;
QImage m_previousImage;
int m_countDownTime;
bool m_showOnionSkin;
int m_onionOpacity;
bool m_upsideDown;
QRect m_subCameraRect;
QRect m_preSubCameraRect;
QPoint m_dragStartPos;
enum SUBHANDLE {
HandleNone,
HandleFrame,
HandleTopLeft,
HandleTopRight,
HandleBottomLeft,
HandleBottomRight,
HandleLeft,
HandleTop,
HandleRight,
HandleBottom
} m_activeSubHandle = HandleNone;
void drawSubCamera(QPainter&);
public:
MyVideoWidget(QWidget* parent = 0);
~MyVideoWidget();
void setImage(const QImage& image) {
m_image = image;
update();
}
QAbstractVideoSurface* videoSurface() const { return m_surface; }
QSize sizeHint() const;
void setShowOnionSkin(bool on) { m_showOnionSkin = on; }
void setOnionOpacity(int value) { m_onionOpacity = value; }
void setPreviousImage(QImage prevImage) { m_previousImage = prevImage; }
void showCountDownTime(int time) {
m_countDownTime = time;
repaint();
}
void setSubCameraSize(QSize size);
QRect subCameraRect() { return m_subCameraRect; }
protected:
void paintEvent(QPaintEvent* event) override;
void resizeEvent(QResizeEvent* event) override;
void mouseMoveEvent(QMouseEvent* event) override;
void mousePressEvent(QMouseEvent* event) override;
void mouseReleaseEvent(QMouseEvent* event) override;
private:
MyVideoSurface* m_surface;
protected slots:
void onUpsideDownChecked(bool on) { m_upsideDown = on; }
signals:
void startCamera();
void stopCamera();
void subCameraResized(bool isDragging);
};
//=============================================================================
// FrameNumberLineEdit
// a special Line Edit which accepts imputting alphabets if the preference
// option
// "Show ABC Appendix to the Frame Number in Xsheet Cell" is active.
//-----------------------------------------------------------------------------
class FrameNumberLineEdit : public DVGui::LineEdit {
Q_OBJECT
/* having two validators and switch them according to the preferences*/
QIntValidator* m_intValidator;
QRegExpValidator* m_regexpValidator;
void updateValidator();
QString m_textOnFocusIn;
public:
FrameNumberLineEdit(QWidget* parent = 0, int value = 1);
~FrameNumberLineEdit() {}
/*! Set text in field to \b value. */
void setValue(int value);
/*! Return an integer with text field value. */
int getValue();
protected:
/*! If focus is lost and current text value is out of range emit signal
\b editingFinished.*/
void focusInEvent(QFocusEvent*) override;
void focusOutEvent(QFocusEvent*) override;
void showEvent(QShowEvent* event) override { updateValidator(); }
};
//=============================================================================
class LevelNameLineEdit : public QLineEdit {
Q_OBJECT
QString m_textOnFocusIn;
public:
LevelNameLineEdit(QWidget* parent = 0);
protected:
void focusInEvent(QFocusEvent* e);
protected slots:
void onEditingFinished();
signals:
void levelNameEdited();
};
//=============================================================================
// FlexibleNameCreator
// Inherits NameCreator, added function for obtaining the previous name and
// setting the current name.
class FlexibleNameCreator final : public NameCreator {
public:
FlexibleNameCreator() {}
std::wstring getPrevious();
bool setCurrent(std::wstring name);
};
//=============================================================================
// PencilTestSaveInFolderPopup
//-----------------------------------------------------------------------------
class PencilTestSaveInFolderPopup : public DVGui::Dialog {
Q_OBJECT
DVGui::FileField* m_parentFolderField;
QLineEdit *m_projectField, *m_episodeField, *m_sequenceField, *m_sceneField,
*m_subFolderNameField;
QCheckBox *m_subFolderCB, *m_autoSubNameCB, *m_createSceneInFolderCB;
QComboBox* m_subNameFormatCombo;
void createSceneInFolder();
public:
PencilTestSaveInFolderPopup(QWidget* parent = 0);
QString getPath();
QString getParentPath();
void updateParentFolder();
protected:
void showEvent(QShowEvent* event);
protected slots:
void updateSubFolderName();
void onAutoSubNameCBClicked(bool);
void onShowPopupOnLaunchCBClicked(bool);
void onCreateSceneInFolderCBClicked(bool);
void onSetAsDefaultBtnPressed();
void onOkPressed();
};
//=============================================================================
// PencilTestPopup
//-----------------------------------------------------------------------------
class PencilTestPopup : public DVGui::Dialog {
Q_OBJECT
QCamera* m_currentCamera;
QString m_deviceName;
MyVideoWidget* m_videoWidget;
QComboBox *m_cameraListCombo, *m_resolutionCombo, *m_fileTypeCombo,
*m_colorTypeCombo;
LevelNameLineEdit* m_levelNameEdit;
QCheckBox *m_upsideDownCB, *m_onionSkinCB, *m_saveOnCaptureCB, *m_timerCB;
QPushButton *m_fileFormatOptionButton, *m_captureWhiteBGButton,
*m_captureButton, *m_loadImageButton;
DVGui::FileField* m_saveInFileFld;
FrameNumberLineEdit* m_frameNumberEdit;
DVGui::IntField *m_bgReductionFld, *m_onionOpacityFld, *m_timerIntervalFld;
QTimer *m_captureTimer, *m_countdownTimer;
QImage m_whiteBGImg;
// used only for Windows
QPushButton* m_captureFilterSettingsBtn;
PencilTestSaveInFolderPopup* m_saveInFolderPopup;
CameraCaptureLevelControl* m_camCapLevelControl;
QLabel* m_frameInfoLabel;
QToolButton* m_previousLevelButton;
QPushButton* m_subcameraButton;
DVGui::IntLineEdit *m_subWidthFld, *m_subHeightFld;
QSize m_allowedCameraSize;
bool m_captureWhiteBGCue;
bool m_captureCue;
bool m_alwaysOverwrite = false;
void processImage(QImage& procImage);
bool importImage(QImage image);
void setToNextNewLevel();
void updateLevelNameAndFrame(std::wstring levelName);
public:
PencilTestPopup();
~PencilTestPopup();
protected:
void showEvent(QShowEvent* event);
void hideEvent(QHideEvent* event);
void keyPressEvent(QKeyEvent* event);
bool event(QEvent* e) override;
protected slots:
void refreshCameraList();
void onCameraListComboActivated(int index);
void onResolutionComboActivated(const QString&);
void onFileFormatOptionButtonPressed();
void onLevelNameEdited();
void onNextName();
void onPreviousName();
void onColorTypeComboChanged(int index);
void onFrameCaptured(QImage& image);
void onCaptureWhiteBGButtonPressed();
void onOnionCBToggled(bool);
void onLoadImageButtonPressed();
void onOnionOpacityFldEdited();
void onTimerCBToggled(bool);
void onCaptureTimerTimeout();
void onCountDown();
void onCaptureButtonClicked(bool);
void onCaptureFilterSettingsBtnPressed();
void refreshFrameInfo();
void onSaveInPathEdited();
void onSceneSwitched();
void onSubCameraToggled(bool);
void onSubCameraResized(bool isDragging);
void onSubCameraSizeEdited();
public slots:
void openSaveInFolderPopup();
};
#endif

View file

@ -292,7 +292,7 @@ Dialog::Dialog(QWidget *parent, bool hasButton, bool hasFixedSize,
assert(values.size() == 4);
// Ensure that the dialog is visible in the screen.
// The dialog opens with some offset to bottom-right direction
// if a flag Qt::WindowMaximizeButtonHint is set. (e.g. PencilTestPopup)
// if a flag Qt::WindowMaximizeButtonHint is set.
// Therefore, if the dialog is moved to the bottom-end of the screen,
// it will be got out of the screen on the next launch.
// The following position adjustment will also prevent such behavior.