PARP Research Group University of Murcia, Spain


src/qvgui/qvcamerawidgetsmall.cpp

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007, 2008. PARP Research Group.
00003  *      <http://perception.inf.um.es>
00004  *      University of Murcia, Spain.
00005  *
00006  *      This file is part of the QVision library.
00007  *
00008  *      QVision is free software: you can redistribute it and/or modify
00009  *      it under the terms of the GNU Lesser General Public License as
00010  *      published by the Free Software Foundation, version 3 of the License.
00011  *
00012  *      QVision is distributed in the hope that it will be useful,
00013  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *      GNU Lesser General Public License for more details.
00016  *
00017  *      You should have received a copy of the GNU Lesser General Public
00018  *      License along with QVision. If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00024 
00025 #include <qvgui/qvcamerawidgetsmall.h>
00026 
00027 QVCameraWidgetSmall::QVCameraWidgetSmall(QVCamera *camera, QWidget *parent): QWidget(parent)
00028         {
00029         form.setupUi(this);
00030         this->camera = camera;
00031         this->cameraWidget = new QVCameraWidget(camera);
00032 
00033         form.groupBox->setTitle(camera->getName());
00034         this->sliderActive = true;
00035 
00036         if (this->camera->isLiveCamera())
00037                 form.seekSlider->setEnabled(false);
00038 
00039         // Connection of signals in camera control widget to private slots...
00040         connect(form.pause_button,SIGNAL(pressed()),camera,SLOT(pauseCam()));
00041         connect(form.play_button,SIGNAL(pressed()),camera,SLOT(unpauseCam()));
00042         connect(form.next_button,SIGNAL(pressed()),camera,SLOT(nextFrameCam()));
00043         connect(form.stop_button, SIGNAL(pressed()),camera,SLOT(closeCam()));
00044 
00045         connect(form.expand_button, SIGNAL(pressed()), cameraWidget,SLOT(show()));
00047 
00048         connect(form.seekSlider,SIGNAL(sliderPressed()),this,SLOT(seekPressedSlot()));
00049         connect(form.seekSlider,SIGNAL(sliderReleased()),this,SLOT(seekReleasedSlot()));
00050         connect(form.seekSlider,SIGNAL(valueChanged(int)),this,SLOT(seekMovedSlot()));
00051         connect(form.seekSlider,SIGNAL(sliderMoved(int)),this,SLOT(seekMovedSlot()));
00052 
00053         // ...and from private signals to public camera slots...
00054         connect(this,SIGNAL(speedPressed(double)), camera,SLOT(setSpeedCam(double)));
00055         connect(this,SIGNAL(seekPressed(QVCamera::TSeekType,double)), camera, SLOT(seekCam(QVCamera::TSeekType,double)));
00056         
00057         // ... and, finally, of camera newGrab and newRead signals to the
00058         // updateVisibleInfo slot...
00059         connect(camera,SIGNAL(newGrab()),this,SLOT(updateCameraVisibleInfoSlot()));
00060         connect(camera,SIGNAL(newRead()),this,SLOT(updateCameraVisibleInfoSlot()));
00061         connect(camera,SIGNAL(statusChange(QVCamera::TCameraStatus)),
00062                 this,SLOT(updateCameraStateSlot(QVCamera::TCameraStatus)));
00063 
00064         // ... and the closed signal of the camera, also to the closePressed slot:
00065         //connect(camera,SIGNAL(camClosed()),this,SLOT(closePressedSlot()));
00066         }
00067 
00068 QVCameraWidgetSmall::~QVCameraWidgetSmall()
00069         {
00070                 delete this->cameraWidget;
00071         }
00072 
00073 void QVCameraWidgetSmall::seekPressedSlot()
00074         {
00075         sliderActive = false;
00076         }
00077 
00078 void QVCameraWidgetSmall::seekReleasedSlot()
00079         {
00080         sliderActive = true;
00081         emit seekPressed((QVCamera::TSeekType)1,form.seekSlider->value());
00082         }
00083 
00084 void QVCameraWidgetSmall::seekMovedSlot()
00085         {
00086         //emit seekPressed((QVCamera::TSeekType)1,form.seekSlider->value());
00087         }
00088 
00089 void QVCameraWidgetSmall::updateCameraVisibleInfoSlot()
00090         {
00091         int percen = (int)((100*camera->getTimePos())/camera->getTimeLength());
00092         if (sliderActive) form.seekSlider->setValue(percen);
00093         }
00094 
00095 void QVCameraWidgetSmall::updateCameraStateSlot(QVCamera::TCameraStatus status)
00096         {
00097         qDebug() << "QVCameraWidgetSmall::updateCameraStateSlot()";
00098         qDebug() << "QVCameraWidgetSmall::updateCameraStateSlot(): new state id:" << status;
00099         switch(status)
00100                 {
00101                 case QVCamera::Closed:
00102                         qDebug() << "QVCameraWidgetSmall::updateCameraStateSlot(): new state: Closed";
00103                         form.stop_button->setEnabled(FALSE);
00104                         form.pause_button->setEnabled(FALSE);
00105                         form.play_button->setEnabled(FALSE);
00106                         form.next_button->setEnabled(FALSE);
00107                         form.expand_button->setEnabled(FALSE);
00108                         break;
00109 
00110                 case QVCamera::Running:
00111                         qDebug() << "QVCameraWidgetSmall::updateCameraStateSlot(): new state: Running";
00112                         form.stop_button->setEnabled(TRUE);
00113                         form.pause_button->setEnabled(TRUE);
00114                         form.play_button->setEnabled(FALSE);
00115                         form.next_button->setEnabled(FALSE);
00116                         form.expand_button->setEnabled(TRUE);
00117                         break;
00118 
00119                 case QVCamera::RunningOneStep:
00120                         qDebug() << "QVCameraWidgetSmall::updateCameraStateSlot(): new state: Running one step";
00121 
00122                 case QVCamera::Paused:
00123                         qDebug() << "QVCameraWidgetSmall::updateCameraStateSlot(): new state: Paused";
00124                         form.stop_button->setEnabled(TRUE);
00125                         form.pause_button->setEnabled(FALSE);
00126                         form.play_button->setEnabled(TRUE);
00127                         form.next_button->setEnabled(TRUE);
00128                         form.expand_button->setEnabled(TRUE);
00129                         break;
00130 
00131                 default:
00132                         break;
00133                 }
00134 
00135         qDebug() << "QVCameraWidgetSmall::updateCameraStateSlot() <~ return";
00136         }



QVision framework. PARP research group, copyright 2007, 2008.