added custom cycle mode

This commit is contained in:
Jared Bruni
2020-01-07 07:35:31 -08:00
parent 003ca28065
commit a55e6953d9
6 changed files with 67 additions and 9 deletions

View File

@@ -425,13 +425,17 @@ void AC_MainWindow::createMenu() {
repeat_v->setCheckable(true);
repeat_v->setChecked(false);
cycle_custom = new QAction(tr("Cycle Custom"), this);
cycle_custom->setCheckable(true);
cycle_custom->setChecked(false);
fade_on = new QAction(tr("Fade"), this);
fade_on->setCheckable(true);
fade_on->setChecked(true);
options->addAction(fade_on);
options->addAction(repeat_v);
options->addAction(cycle_custom);
connect(cycle_custom, SIGNAL(triggered()), this, SLOT(setCustomCycle_Menu()));
connect(fade_on, SIGNAL(triggered()), this, SLOT(setFade()));
connect(repeat_v, SIGNAL(triggered()), this, SLOT(repeat_vid()));
connect(clear_image, SIGNAL(triggered()), this, SLOT(clear_img()));
@@ -1685,3 +1689,8 @@ void AC_MainWindow::setRandomFilterValue() {
int filter_index = ac::filter_map[filter_name];
filters->setCurrentIndex(filter_index);
}
void AC_MainWindow::setCustomCycle_Menu() {
bool chk = cycle_custom->isChecked();
playback->setCustomCycle(chk);
}

View File

@@ -60,6 +60,7 @@ public:
QAction *show_options_window;
QAction *show_control_window;
QAction *select_random_filter;
QAction *cycle_custom;
double speed_actions[7];
QRadioButton *filter_single, *filter_custom;
void updateList();
@@ -128,6 +129,7 @@ public slots:
void showImageWindow();
void showPrefWindow();
void setRandomFilterValue();
void setCustomCycle_Menu();
private:
void createControls();
void createMenu();

View File

@@ -2,7 +2,7 @@
OptionsWindow::OptionsWindow(QWidget *parent) : QDialog(parent) {
setFixedSize(170, 150);
setFixedSize(170, 180);
createControls();
}
@@ -19,9 +19,17 @@ void OptionsWindow::createControls() {
label_z->setGeometry(10, 70, 100, 25);
op_max_frames = new QLineEdit("1500", this);
op_max_frames->setGeometry(110,70, 50, 25);
QLabel *label_q = new QLabel(tr("Delay: "), this);
label_q->setGeometry(10, 100, 100, 25);
fps_delay = new QLineEdit("60", this);
fps_delay->setGeometry(110, 100, 50, 25);
op_setpref = new QPushButton(tr("Set"), this);
op_setpref->setGeometry(10, 110, 100, 25);
op_setpref->setGeometry(10, 140, 100, 25);
connect(op_setpref, SIGNAL(clicked()), this, SLOT(setValues()));
}
void OptionsWindow::setValues() {
@@ -41,10 +49,15 @@ void OptionsWindow::setValues() {
QMessageBox::information(this, tr("Error Requires Max"), tr("Required Max Frames must be greater than 300"));
return;
}
int delay_value = atoi(fps_delay->text().toStdString().c_str());
if(delay_value > 0)
playback->setCustomCycleDelay(delay_value);
ac::setMaxAllocated(max_frames);
QString text;
QTextStream stream(&text);
stream << tr("Thread Count set to: ") << thread_count << tr(" and Intensity set to: ") << intensity << tr("\nMaximum Stored Frames: ") << max_frames << tr("\n");
stream << tr("Thread Count set to: ") << thread_count << tr(" and Intensity set to: ") << intensity << tr("\nMaximum Stored Frames: ") << max_frames << tr("\n") << tr("Delay: ") << delay_value << "\n";;
QMessageBox::information(this, tr("Pref Value Set"), text);
}

View File

@@ -19,6 +19,7 @@ private:
QPushButton *op_setpref;
Playback *playback;
QLineEdit *op_max_frames;
QLineEdit *fps_delay;
};
#endif

View File

@@ -22,6 +22,18 @@ Playback::Playback(QObject *parent) : QThread(parent) {
cycle_on = 0;
cycle_index = 0;
frame_num = 0;
_custom_cycle = false;
_custom_cycle_index = 0;
fps_delay = 60;
}
void Playback::setCustomCycle(bool b) {
_custom_cycle = b;
_custom_cycle_index = 0;
}
void Playback::setCustomCycleDelay(int delay) {
fps_delay = delay;
}
void Playback::Play() {
@@ -333,13 +345,29 @@ void Playback::run() {
} else if(cur.size()>0) {
mutex.lock();
ac::in_custom = true;
if(_custom_cycle == false) {
for(unsigned int i = 0; i < cur.size(); ++i) {
if(i == cur.size()-1)
ac::in_custom = false;
drawFilter(frame, cur[i]);
msleep(duration/2);
}
} else {
if(_custom_cycle_index > static_cast<int>(cur.size()))
_custom_cycle_index = 0;
drawFilter(frame, cur[_custom_cycle_index]);
msleep(duration/2);
}
drawEffects(frame);
static int delay_counter = 0;
++delay_counter;
if(delay_counter > (fps_delay * static_cast<int>(ac::fps))) {
delay_counter = 0;
++_custom_cycle_index;
if(_custom_cycle_index > static_cast<int>(cur.size()))
_custom_cycle_index = 0;
}
mutex.unlock();
} else {
msleep(duration);

View File

@@ -44,6 +44,9 @@ private:
int cycle_on;
int cycle_index;
int frame_num;
bool _custom_cycle;
int _custom_cycle_index;
int fps_delay;
public:
Playback(QObject *parent = 0);
~Playback();
@@ -80,6 +83,8 @@ public:
void setCycle(int type, int frame_skip, std::vector<std::string> &val);
void setCycle(int type);
void setPref(int thread_count, int intense);
void setCustomCycle(bool b);
void setCustomCycleDelay(int delay);
signals:
void procImage(const QImage image);
void stopRecording();