diff --git a/src/goto_window.cpp b/src/goto_window.cpp index 0d5cb73..f4a137b 100644 --- a/src/goto_window.cpp +++ b/src/goto_window.cpp @@ -3,14 +3,39 @@ GotoWindow::GotoWindow(QWidget *parent) : QDialog(parent) { createControls(); - setFixedSize(400, 150); + setFixedSize(400, 70); + setWindowTitle("Jump to Frame"); + setGeometry(300, 50, 400, 70); } + +void GotoWindow::setVideoCapture(cv::VideoCapture *cap) { + capture_device = cap; +} void GotoWindow::setDisplayWindow(DisplayWindow *win) { disp_window = win; } void GotoWindow::createControls() { + goto_pos = new QSlider(Qt::Horizontal, this); + goto_pos->setGeometry(10, 10, 380, 20); + goto_pos->setMaximum(1); + goto_pos->setMinimum(0); + goto_pos->setTickInterval(0); + + QLabel *lbl_sec = new QLabel("Second: ", this); + QLabel *lbl_frame = new QLabel("Frame: ", this); + lbl_sec->setGeometry(10, 30, 50, 20); + lbl_frame->setGeometry(180, 30, 50, 20); + goto_sec = new QLineEdit("0", this); + goto_sec->setGeometry(70,30,100, 20); + goto_frame = new QLineEdit("0", this); + goto_frame->setGeometry(230,30,100,20); + goto_jump = new QPushButton("Go", this); + goto_jump->setGeometry(340, 30, 45, 20); + + connect(goto_jump, SIGNAL(clicked()), this, SLOT(pressedGo())); + connect(goto_pos, SIGNAL(valueChanged(int)), this, SLOT(slideChanged(int))); } @@ -18,6 +43,30 @@ void GotoWindow::setFrameIndex(const long &i) { index = i; } -void GotoWindow::ShowImage() { +void GotoWindow::showImage() { } + +void GotoWindow::showWindow(int min, int max) { + goto_pos->setMaximum(min); + goto_pos->setMaximum(max); + show(); +} + +void GotoWindow::pressedGo() { + QString fpos = goto_frame->text(); + int f_pos = atoi(fpos.toStdString().c_str()); + if(f_pos != goto_pos->sliderPosition()) { + goto_pos->setSliderPosition(f_pos); + } +} + +void GotoWindow::slideChanged(int pos) { + QString text; + QTextStream stream(&text); + stream << static_cast(pos/ac::fps); + goto_sec->setText(text); + text = ""; + stream << (pos); + goto_frame->setText(text); +} diff --git a/src/goto_window.h b/src/goto_window.h index 99888e0..a1dffb1 100644 --- a/src/goto_window.h +++ b/src/goto_window.h @@ -8,13 +8,23 @@ class GotoWindow : public QDialog { Q_OBJECT public: GotoWindow(QWidget *parent); + void setVideoCapture(cv::VideoCapture *cap); void setDisplayWindow(DisplayWindow *win); void createControls(); void setFrameIndex(const long &index); - void ShowImage(); + void showImage(); + void showWindow(int min, int max); private: long index; DisplayWindow *disp_window; + cv::VideoCapture *capture_device; + QSlider *goto_pos; + QLineEdit *goto_sec, *goto_frame; + QPushButton *goto_jump; +public slots: + void pressedGo(); + void slideChanged(int pos); + }; #endif diff --git a/src/main_window.cpp b/src/main_window.cpp index c0649a7..edf7cc2 100644 --- a/src/main_window.cpp +++ b/src/main_window.cpp @@ -75,8 +75,11 @@ AC_MainWindow::AC_MainWindow(QWidget *parent) : QMainWindow(parent) { goto_window = new GotoWindow(this); disp = new DisplayWindow(this); playback = new Playback(); - //goto_window->show(); + + goto_window->showWindow(0, 100); + goto_window->setParent(this); goto_window->setDisplayWindow(disp); + QObject::connect(playback, SIGNAL(procImage(QImage)), this, SLOT(updateFrame(QImage))); QObject::connect(playback, SIGNAL(stopRecording()), this, SLOT(stopRecording())); QObject::connect(playback, SIGNAL(frameIncrement()), this, SLOT(frameInc()));