feat: added QT pause button
This commit is contained in:
parent
7b06a54542
commit
489727663c
|
|
@ -84,7 +84,6 @@ void MainWindow::setupTechniques() {
|
||||||
this->timer->SetClientData(program);
|
this->timer->SetClientData(program);
|
||||||
this->timer->setDt(DT);
|
this->timer->setDt(DT);
|
||||||
intr->AddObserver(vtkCommand::TimerEvent, this->timer);
|
intr->AddObserver(vtkCommand::TimerEvent, this->timer);
|
||||||
intr->AddObserver(vtkCommand::KeyPressEvent, this->timer);
|
|
||||||
intr->CreateRepeatingTimer(17); // 60 fps == 1000 / 60 == 16.7 ms per frame
|
intr->CreateRepeatingTimer(17); // 60 fps == 1000 / 60 == 16.7 ms per frame
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -236,3 +235,6 @@ void MainWindow::on_IregularlySubsampledButton_clicked(bool checked) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_pauseButton_clicked(bool checked) {
|
||||||
|
this->timer->togglePaused();
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ private slots:
|
||||||
void on_FullySampledButton_clicked(bool checked);
|
void on_FullySampledButton_clicked(bool checked);
|
||||||
void on_RegularlySubsampledButton_clicked(bool checked);
|
void on_RegularlySubsampledButton_clicked(bool checked);
|
||||||
void on_IregularlySubsampledButton_clicked(bool checked);
|
void on_IregularlySubsampledButton_clicked(bool checked);
|
||||||
|
void on_pauseButton_clicked(bool checked);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow* ui;
|
Ui::MainWindow* ui;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include <QtWidgets/QRadioButton>
|
#include <QtWidgets/QRadioButton>
|
||||||
#include <QtWidgets/QVBoxLayout>
|
#include <QtWidgets/QVBoxLayout>
|
||||||
#include <QtWidgets/QWidget>
|
#include <QtWidgets/QWidget>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
@ -54,6 +55,7 @@ public:
|
||||||
QRadioButton *RegularlySubsampledButton;
|
QRadioButton *RegularlySubsampledButton;
|
||||||
QRadioButton *IregularlySubsampledButton;
|
QRadioButton *IregularlySubsampledButton;
|
||||||
Program *program;
|
Program *program;
|
||||||
|
QPushButton *pauseButton;
|
||||||
|
|
||||||
void setupUi(QMainWindow *MainWindow)
|
void setupUi(QMainWindow *MainWindow)
|
||||||
{
|
{
|
||||||
|
|
@ -234,6 +236,12 @@ public:
|
||||||
|
|
||||||
horizontalLayout->addWidget(program);
|
horizontalLayout->addWidget(program);
|
||||||
|
|
||||||
|
|
||||||
|
pauseButton = new QPushButton("pause", settingsBox);
|
||||||
|
pauseButton->setGeometry(QRect(QPoint(100, 100), QSize(200, 50)));
|
||||||
|
pauseButton->setObjectName(QString::fromUtf8("pauseButton"));
|
||||||
|
verticalLayout_3->addWidget(pauseButton);
|
||||||
|
|
||||||
MainWindow->setCentralWidget(centralWidget);
|
MainWindow->setCentralWidget(centralWidget);
|
||||||
|
|
||||||
retranslateUi(MainWindow);
|
retranslateUi(MainWindow);
|
||||||
|
|
@ -265,6 +273,7 @@ public:
|
||||||
FullySampledButton->setText(QCoreApplication::translate("MainWindow", "Fully sampled", nullptr));
|
FullySampledButton->setText(QCoreApplication::translate("MainWindow", "Fully sampled", nullptr));
|
||||||
RegularlySubsampledButton->setText(QCoreApplication::translate("MainWindow", "Regularly subsampled", nullptr));
|
RegularlySubsampledButton->setText(QCoreApplication::translate("MainWindow", "Regularly subsampled", nullptr));
|
||||||
IregularlySubsampledButton->setText(QCoreApplication::translate("MainWindow", "Irregularly subsampled", nullptr));
|
IregularlySubsampledButton->setText(QCoreApplication::translate("MainWindow", "Irregularly subsampled", nullptr));
|
||||||
|
pauseButton->setText(QCoreApplication::translate("MainWindow", "Pause Simulation", nullptr));
|
||||||
} // retranslateUi
|
} // retranslateUi
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,7 @@ TimerCallbackCommand* TimerCallbackCommand::New(Program *program) {
|
||||||
void TimerCallbackCommand::Execute(vtkObject* caller, unsigned long eventId, void* vtkNotUsed(callData)) {
|
void TimerCallbackCommand::Execute(vtkObject* caller, unsigned long eventId, void* vtkNotUsed(callData)) {
|
||||||
auto intr = reinterpret_cast<vtkRenderWindowInteractor *>(caller);
|
auto intr = reinterpret_cast<vtkRenderWindowInteractor *>(caller);
|
||||||
|
|
||||||
if (eventId == vtkCommand::KeyPressEvent and not strcmp("space", intr->GetKeySym())) {
|
if (eventId == vtkCommand::TimerEvent and not this->paused) {
|
||||||
this->paused = ! this->paused;
|
|
||||||
} else if (eventId == vtkCommand::TimerEvent and not this->paused) {
|
|
||||||
this->time += this->dt;
|
this->time += this->dt;
|
||||||
|
|
||||||
if (this->time >= this->maxTime) {
|
if (this->time >= this->maxTime) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue