diff --git a/mainwindow.cpp b/mainwindow.cpp index 57e8fa5..b749b58 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -47,25 +47,32 @@ void MainWindow::closeEvent(QCloseEvent *event) //! [2] //! [3] -void MainWindow::open() +void MainWindow::askOpen() //! [3] //! [4] { if (maybeSave()) { - QString path=QDir::currentPath(); + qInfo()<<"maybeSave ok so askOpen continues..."; + QString defaultPaths=QDir::currentPath(); //QString tryPath="C:\\Users\\Owner\\Videos\\NTWAOG (Music Video)\\Media\\Sequence 00092 hovering\\00092a"; QString tryPath="C:\\Users\\Owner\\Videos\\ImageSequenceExamples"; - QDir defaultDir=QDir(tryPath); - if (defaultDir.exists()) path=tryPath; + QDir tryDir=QDir(tryPath); + if (tryDir.exists()) defaultPath=tryPath; QString fileName = QFileDialog::getOpenFileName(this, - tr("Open File"), path); - if (!fileName.isEmpty()) + tr("Open File"), defaultPath); + if (!fileName.isEmpty()) { + qInfo()<<"opening file..."; rotocanvas->openImage(fileName); + qInfo()<<"opened."; + } + else { + qInfo()<<"can't open since no name."; + } } } //! [4] //! [5] -void MainWindow::save() +void MainWindow::askSave() //! [5] //! [6] { QAction *action = qobject_cast(sender()); @@ -140,18 +147,18 @@ void MainWindow::createActions() { openAct = new QAction(tr("&Open..."), this); openAct->setShortcuts(QKeySequence::Open); - connect(openAct, SIGNAL(triggered()), this, SLOT(open())); + connect(openAct, SIGNAL(triggered()), this, SLOT(askOpen())); saveFrameAct = new QAction(tr("&Save..."), this); saveFrameAct->setShortcut(QKeySequence::Save); - connect(saveFrameAct, SIGNAL(triggered()), this, SLOT(save())); + connect(saveFrameAct, SIGNAL(triggered()), this, SLOT(askSave())); foreach (QByteArray format, QImageWriter::supportedImageFormats()) { QString text = tr("%1...").arg(QString(format).toUpper()); QAction *action = new QAction(text, this); action->setData(format); - connect(action, SIGNAL(triggered()), this, SLOT(save())); + connect(action, SIGNAL(triggered()), this, SLOT(askSave())); saveAsActs.append(action); } diff --git a/mainwindow.h b/mainwindow.h index f4fcb4b..7a77a1a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -20,8 +20,8 @@ protected: void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; private slots: - void open(); - void save(); + void askOpen(); + void askSave(); void askBrushColor(); void askBrushOpacity(); void askBrushRadius(); diff --git a/rotocanvas.cpp b/rotocanvas.cpp index cc99f96..a8ade04 100644 --- a/rotocanvas.cpp +++ b/rotocanvas.cpp @@ -43,8 +43,14 @@ QString RotoCanvas::getSeqName(QString framePath) QString RotoCanvas::getSeqName(QFileInfo frameFI) { QString result; - QString baseName=frameFI.completeBaseName(); //baseName would get file from file.tar.gz, completeBaseName gets file.tar + QString baseName=frameFI.completeBaseName(); //baseName would get file from file.tar.gz or from file.myvideo0000.png, where completeBaseName gets file.tar or file.myvideo0000 result=baseName; + // now remove any trailing digits to get the "sequence name": + int newLength=result.length(); + while ( newLength>0 && baseName.at(newLength-1).isDigit() ) { + newLength--; + } + if (newLength!=result.length()) result = result.left(newLength); return result; } @@ -103,6 +109,7 @@ QString RotoCanvas::getSeqPaddedFrameNumber(QFileInfo frameFI) { QString baseName=frameFI.completeBaseName(); int digitCount=RotoCanvas::getSeqDigitCount(frameFI); + //qInfo()<<"getSeqPaddedFrameNumber digitCount:"</frames//layers QString seqName=RotoCanvas::getSeqName(frameFI); - qInfo() << "seqName:" << seqName; //see also qInfo,qDebug,qWarning,qCritical,qFatal + //qInfo() << "seqName:" << seqName; //see also qInfo,qDebug,qWarning,qCritical,qFatal QString seqPath=frameFI.dir().filePath(seqName); QDir seqDir(seqPath); if (createEnable) { if (!seqDir.exists()) frameFI.dir().mkdir(seqName); } - QString framesPath=frameFI.dir().filePath("frames"); - qInfo()<<"framesPath:"<0 && resultString.left(1)=="0") { - resultString=resultString.right(resultString.length()-1); + if (resultString.length()>0) { + int newLength=resultString.length(); + int index=0; + while (index0) result=baseName.left(baseName.length()-digitCount).toInt(); + if (digitCount>0) result=digitCount; // result=baseName.left(baseName.length()-digitCount).toInt(); return result; } @@ -353,7 +368,7 @@ bool RotoCanvas::getIsModified() bool RotoCanvas::openImage(const QString &fileName) //! [1] //! [2] { - + qInfo()<<"RotoCanvas::openImage..."; QImage loadedImage; if (!loadedImage.load(fileName)) return false; @@ -367,28 +382,31 @@ bool RotoCanvas::openImage(const QString &fileName) //this->formatString = loadedFI.suffix(); QSize newSize = loadedImage.size().expandedTo(size()); //resizeImage(&loadedImage, this->outputSize); - resizeImage(&panelImage, newSize); //resizeImage(&) + resizeImage(&panelImage, newSize); // resizeImage(&) fillCheckered(&panelImage); - /// Load the source frame as originalImage: - originalImage = QImage(loadedImage.size(),QImage::Format_ARGB32); + /// Load the source frame as originalImage (converting to 32-bit): + originalImage = QImage(loadedImage.size(), QImage::Format_ARGB32); originalImage.fill(qRgba(0,0,0,0)); QPainter bgPainter(&originalImage); - bgPainter.drawImage(QPoint(0,0),loadedImage);//originalImage = loadedImage; + bgPainter.drawImage(QPoint(0,0), loadedImage); // originalImage = loadedImage; QPainter displayPainter(&panelImage); - + displayPainter.drawImage(QPoint(0,0), originalImage); //isModified = false; while (layerPtrs.length()>0) { RotoCanvasLayer* thisLayer=layerPtrs.takeLast(); if (thisLayer!=nullptr) delete thisLayer; } - QString layersPath=getLayersFolderPath(getSeqFrameNumber(),false); + int frameNumber=getSeqFrameNumber(); + qInfo()<<"frameNumber: "<width()>thisImage->height())?thisImage->width():thisImage->height()) / 200; if (thisImage!=nullptr) { //QSize newSize=thisImage->size(); thisImage->fill(this->checkerDarkColor); //newImage.fill(qRgb(255, 255, 255)); for (int y=0; yheight(); y++) { for (int x=0; xwidth(); x++) { //debug optimization: try lines instead of pixel - if (y%2==1) { - if (x%2==1) thisImage->setPixelColor(x, y, this->checkerLightColor); + if ((y/checkerPxCount)%2==1) { + if ((x/checkerPxCount)%2==1) thisImage->setPixelColor(x, y, this->checkerLightColor); } else { - if ((x+1)%2==1) thisImage->setPixelColor(x, y, this->checkerLightColor); + if (((x/checkerPxCount)+1)%2==1) thisImage->setPixelColor(x, y, this->checkerLightColor); } } } @@ -674,6 +695,7 @@ void RotoCanvas::fillCheckered(QImage *thisImage) void RotoCanvas::resizeImage(QImage *image, const QSize &newSize) //! [19] //! [20] { + //qInfo()<<"resizing..."; if (image->size() == newSize) return; @@ -683,6 +705,7 @@ void RotoCanvas::resizeImage(QImage *image, const QSize &newSize) QPainter painter(&newImage); painter.drawImage(QPoint(0, 0), *image); *image = newImage; + //qInfo()<<"done (resizing)"; } QImage RotoCanvas::getCacheableImage(QString filePath)