/** * Sets next image to image label. */ void Photo_Viewer::nextImage() { //using dynamic memory char* filename; //check if a next image exists if (getImgLoc()<files.size()-1) { //current image location + 1 string str = files.at(getImgLoc() + 1); filename = new char[str.length() + 1]; //copy string to char strcpy(filename, str.c_str()); //change image setNewImage(filename); //free up memory delete[] filename; //set new image location to be one number higher setImgLoc(getImgLoc() + 1); }else { //get the first image string str = files.at(0); filename = new char[str.length() + 1]; //copy string to char strcpy(filename, str.c_str()); //change image setNewImage(filename); //free up memory delete[] filename; //set image location to first image setImgLoc(0); } }
/** * Sets previous image to image label. */ void Photo_Viewer::previousImage() { //using dynamic memory char* filename; //check if a previous image exists if (getImgLoc()>0) { //current image location - 1 string str = files.at(getImgLoc() - 1); filename = new char[str.length() + 1]; //copy string to char strcpy(filename, str.c_str()); //change image setNewImage(filename); //free up memory delete[] filename; //set new image location to be one number lower setImgLoc(getImgLoc() - 1); } else { //get the last image string str = files.at(files.size() - 1); filename = new char[str.length() + 1]; //copy string to char strcpy(filename, str.c_str()); //change image setNewImage(filename); //free up memory delete[] filename; //set image location to last image setImgLoc(files.size() - 1); } }
QVideoDisplay::~QVideoDisplay() { BOOST_LOG_TRIVIAL(trace) << __LINE__ << "QVideoDisplay::~QVideoDisplay()"; _imgProvider->stopUpdating(); disconnect(_imgProvider, SIGNAL(newImageAvailable()), this, SLOT(setNewImage())); delete _imgProvider; _imgProvider = nullptr; _dctrl->stopVideo(); }
QVideoDisplay::QVideoDisplay(DeviceController* pdc, QWidget* parent) : _dctrl(pdc), QWidget(parent) { BOOST_LOG_TRIVIAL(trace) << __LINE__ << "QVideoDisplay::QVideoDisplay()"; setupUi(this); int frameRate = 1000 / 24; // 24 frames per second VideoFrameFeed* feed = _dctrl->startVideo(); _imgProvider = new QImageProvider(feed, frameRate); connect(_imgProvider, SIGNAL(newImageAvailable()), this, SLOT(setNewImage())); _imgProvider->startUpdating(); }
// Go to a specific position of stream virtual void setReferenceTime( double time ) { OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex); int i=1; int framePos = static_cast<int>(time*100.0/_multiplier); if ( framePos>=(int)_length ) framePos = _length; std::vector<FrameData*>::iterator it; for ( it=_dataList.begin(); it!=_dataList.end(); it++,i++ ) { framePos -= (*it)->delay; if ( framePos<0 ) break; } _dataNum = i-1; _frameNum = (*it)->delay+framePos; setNewImage(); }
/** * Creates an image label that fills QMainWindow and reloads the first * image and scales it to the size of the label. */ void Photo_Viewer::createImageLabel() { imgLbl = new QLabel(this); imgLbl->setBackgroundRole(QPalette::Base); imgLbl->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); //using dynamic memory char* filename; //get the current image location string str = files.at(getImgLoc()); filename = new char[str.length() + 1]; //copy string to char strcpy(filename, str.c_str()); //change image setNewImage(filename); //free up memory delete[] filename; imgLbl->resize(maxWidth, maxHeight); imgLbl->setScaledContents(TRUE); imgLbl->show(); }
virtual void run() { _dataIter = _dataList.begin(); while ( !_done ) { if ( _status==PLAYING && (*_dataIter) ) { if ( _frameNum>=(*_dataIter)->delay ) { _frameNum = 0; if ( _dataNum>=_dataList.size()-1 ) { if ( getLoopingMode()==LOOPING ) { _dataNum = 0; _currentLength = 0; } } else _dataNum++; setNewImage(); } else { _frameNum++; _currentLength++; } OpenThreads::Thread::microSleep(static_cast<int>(10000.0f*_multiplier)); } else OpenThreads::Thread::microSleep(150000L); } }
QvkWebcamController::QvkWebcamController( QCheckBox *myCheckBox, QComboBox *myComboBox, QCheckBox *myMirrorCheckBox, QFrame *myRotateFrame ,QDial *myRotateDial, QRadioButton *myRadioButtonTopMiddle, QRadioButton *myRadioButtonRightMiddle, QRadioButton *myRadioButtonBottomMiddle, QRadioButton *myRadioButtonLeftMiddle ) { vkSettings.readAll(); checkBox = myCheckBox; checkBox->setEnabled( false ); connect( checkBox, SIGNAL( clicked( bool ) ), this, SLOT( setWebcamOnOff( bool ) ) ); rotateFrame = myRotateFrame; comboBox = myComboBox; mirrored = false; mirrorCheckBox = myMirrorCheckBox; if ( checkBox->checkState() == Qt::Unchecked ) { mirrorCheckBox->setEnabled( false ); rotateFrame->setEnabled( false ); } else { mirrorCheckBox->setEnabled( true ); rotateFrame->setEnabled( false ); } connect( mirrorCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( setMirrorOnOff( bool ) ) ); if ( vkSettings.getWebcamMirrored() == Qt::Checked ) { mirrorCheckBox->setEnabled( true ); mirrorCheckBox->click(); mirrorCheckBox->setEnabled( false ); } rotateDial = myRotateDial; rotateDial->setMinimum( 0 ); rotateDial->setMaximum ( 360 ); rotateDial->setValue( 0 ); connect( rotateDial, SIGNAL( sliderPressed () ), this, SLOT( rotateDialclicked() ) ); radioButtonTopMiddle = myRadioButtonTopMiddle; radioButtonTopMiddle->setChecked( vkSettings.getWebcamButtonTopMiddle() ); radioButtonRightMiddle = myRadioButtonRightMiddle; radioButtonRightMiddle->setChecked( vkSettings.getWebcamButtonRightMiddle() ); radioButtonBottomMiddle = myRadioButtonBottomMiddle; radioButtonBottomMiddle->setChecked( vkSettings.getWebcamButtonBottomMiddle() ); radioButtonLeftMiddle = myRadioButtonLeftMiddle; radioButtonLeftMiddle->setChecked( vkSettings.getWebcamButtonLeftMiddle() ); captureThread = new CaptureThread(); connect( captureThread, SIGNAL( newPicture( QImage ) ), this, SLOT( setNewImage( QImage ) ) ); myWebcamWatcher = new QvkWebcamWatcher(); connect( myWebcamWatcher, SIGNAL( changed( QStringList ) ), this, SLOT( webcamChangedEvent( QStringList ) ) ); connect( myWebcamWatcher, SIGNAL( removed( QStringList, QString ) ), this, SLOT( webcamRemovedEvent( QStringList, QString ) ) ); myWebcamWatcher->myfileSystemWatcher( "/dev/" ); webcamWindow = new QvkWebcamWindow(); connect( webcamWindow, SIGNAL( setOverScreen() ), this, SLOT( checkBox_OnOff() ) ); connect( webcamWindow, SIGNAL( closeWebcamWindow() ), SLOT( webcamCloseEvent() ) ); connect( myWebcamWatcher, SIGNAL( readWebcamNames( QStringList ) ), this, SLOT( readWebcams( QStringList ) ) ); }