diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2020-01-11 15:48:43 +0100 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2020-01-11 15:48:43 +0100 |
commit | 0bf8fa23d91ae9bc46a45a4a2d8d12061e54c742 (patch) | |
tree | e3ba4ae0f3abae7d5c09debf76bfb872feb64d56 /gui | |
parent | 3f439c1ef2c1f4b7694d05be53117f0afe97cc17 (diff) | |
download | nextpnr-0bf8fa23d91ae9bc46a45a4a2d8d12061e54c742.tar.gz nextpnr-0bf8fa23d91ae9bc46a45a4a2d8d12061e54c742.tar.bz2 nextpnr-0bf8fa23d91ae9bc46a45a4a2d8d12061e54c742.zip |
Skip same frames
Diffstat (limited to 'gui')
-rw-r--r-- | gui/basewindow.cc | 14 | ||||
-rw-r--r-- | gui/fpgaviewwidget.cc | 19 | ||||
-rw-r--r-- | gui/fpgaviewwidget.h | 4 |
3 files changed, 24 insertions, 13 deletions
diff --git a/gui/basewindow.cc b/gui/basewindow.cc index 0bfc59a3..7f767c58 100644 --- a/gui/basewindow.cc +++ b/gui/basewindow.cc @@ -25,6 +25,7 @@ #include <QIcon>
#include <QImageWriter>
#include <QInputDialog>
+#include <QMessageBox>
#include <QSplitter>
#include <fstream>
#include "designwidget.h"
@@ -400,11 +401,14 @@ void BaseMainWindow::saveMovie() QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (!dir.isEmpty()) {
bool ok;
- int frames = QInputDialog::getInt(this, "Skip frames", tr("Frames to skip (1 frame = 50ms):"), 5, 0, 1000,
- 1, &ok);
- if (ok)
- fpgaView->movieStart(dir, frames);
- else
+ int frames =
+ QInputDialog::getInt(this, "Recording", tr("Frames to skip (1 frame = 50ms):"), 5, 0, 1000, 1, &ok);
+ if (ok) {
+ QMessageBox::StandardButton reply =
+ QMessageBox::question(this, "Recording", "Skip identical frames ?",
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
+ fpgaView->movieStart(dir, frames, (reply == QMessageBox::Yes));
+ } else
actionMovie->setChecked(false);
} else
actionMovie->setChecked(false);
diff --git a/gui/fpgaviewwidget.cc b/gui/fpgaviewwidget.cc index 8730c9d9..f1494452 100644 --- a/gui/fpgaviewwidget.cc +++ b/gui/fpgaviewwidget.cc @@ -329,14 +329,17 @@ void FPGAViewWidget::paintGL() if (movieCounter == currentFrameSkip) { QMutexLocker lock(&rendererArgsLock_); movieCounter = 0; - currentMovieFrame++; - QImage image = grabFramebuffer(); - QString number = QString("movie_%1.png").arg(currentMovieFrame, 5, 10, QChar('0')); + if (!movieSkipSame || movieLastImage != image) { + currentMovieFrame++; + + QString number = QString("movie_%1.png").arg(currentMovieFrame, 5, 10, QChar('0')); - QFileInfo fileName = QFileInfo(QDir(movieDir), number); - QImageWriter imageWriter(fileName.absoluteFilePath(), "png"); - imageWriter.write(image); + QFileInfo fileName = QFileInfo(QDir(movieDir), number); + QImageWriter imageWriter(fileName.absoluteFilePath(), "png"); + imageWriter.write(image); + movieLastImage = image; + } } else { movieCounter++; } @@ -599,9 +602,11 @@ void FPGAViewWidget::renderLines(void) } } -void FPGAViewWidget::movieStart(QString dir, long frameSkip) +void FPGAViewWidget::movieStart(QString dir, long frameSkip, bool skipSame) { QMutexLocker locker(&rendererArgsLock_); + movieLastImage = QImage(); + movieSkipSame = skipSame; movieDir = dir; currentMovieFrame = 0; movieCounter = 0; diff --git a/gui/fpgaviewwidget.h b/gui/fpgaviewwidget.h index 7f99408e..9f670cb0 100644 --- a/gui/fpgaviewwidget.h +++ b/gui/fpgaviewwidget.h @@ -120,7 +120,7 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions void zoomSelected(); void zoomOutbound(); void enableDisableDecals(bool bels, bool wires, bool pips, bool groups); - void movieStart(QString dir, long frameSkip); + void movieStart(QString dir, long frameSkip, bool skipSame); void movieStop(); Q_SIGNALS: void clickedBel(BelId bel, bool add); @@ -133,6 +133,8 @@ class FPGAViewWidget : public QOpenGLWidget, protected QOpenGLFunctions long currentFrameSkip; long movieCounter; bool movieSaving; + bool movieSkipSame; + QImage movieLastImage; const float zoomNear_ = 0.05f; // do not zoom closer than this float zoomFar_ = 10.0f; // do not zoom further than this const float zoomLvl1_ = 1.0f; |