working on goto window

This commit is contained in:
lostjared
2018-08-30 04:05:58 -07:00
parent 72bd7d2473
commit 5ff297fc8f
3 changed files with 66 additions and 4 deletions

View File

@@ -3,14 +3,39 @@
GotoWindow::GotoWindow(QWidget *parent) : QDialog(parent) { GotoWindow::GotoWindow(QWidget *parent) : QDialog(parent) {
createControls(); 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) { void GotoWindow::setDisplayWindow(DisplayWindow *win) {
disp_window = win; disp_window = win;
} }
void GotoWindow::createControls() { 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; 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<int>(pos/ac::fps);
goto_sec->setText(text);
text = "";
stream << (pos);
goto_frame->setText(text);
}

View File

@@ -8,13 +8,23 @@ class GotoWindow : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
GotoWindow(QWidget *parent); GotoWindow(QWidget *parent);
void setVideoCapture(cv::VideoCapture *cap);
void setDisplayWindow(DisplayWindow *win); void setDisplayWindow(DisplayWindow *win);
void createControls(); void createControls();
void setFrameIndex(const long &index); void setFrameIndex(const long &index);
void ShowImage(); void showImage();
void showWindow(int min, int max);
private: private:
long index; long index;
DisplayWindow *disp_window; 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 #endif

View File

@@ -75,8 +75,11 @@ AC_MainWindow::AC_MainWindow(QWidget *parent) : QMainWindow(parent) {
goto_window = new GotoWindow(this); goto_window = new GotoWindow(this);
disp = new DisplayWindow(this); disp = new DisplayWindow(this);
playback = new Playback(); playback = new Playback();
//goto_window->show();
goto_window->showWindow(0, 100);
goto_window->setParent(this);
goto_window->setDisplayWindow(disp); goto_window->setDisplayWindow(disp);
QObject::connect(playback, SIGNAL(procImage(QImage)), this, SLOT(updateFrame(QImage))); QObject::connect(playback, SIGNAL(procImage(QImage)), this, SLOT(updateFrame(QImage)));
QObject::connect(playback, SIGNAL(stopRecording()), this, SLOT(stopRecording())); QObject::connect(playback, SIGNAL(stopRecording()), this, SLOT(stopRecording()));
QObject::connect(playback, SIGNAL(frameIncrement()), this, SLOT(frameInc())); QObject::connect(playback, SIGNAL(frameIncrement()), this, SLOT(frameInc()));