src/qvgui/qvworkerinterfacesmall.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/qvworkerinterfacesmall.h>
00026 
00027 QVWorkerInterfaceSmall::QVWorkerInterfaceSmall(QVWorker *worker, QWidget *parent): QWidget(parent), cpuPlot(0)
00028         {
00029         qDebug() << "QVWorkerInterfaceSmall::QVWorkerInterfaceSmall("<< worker->getName() << ")";
00030         form.setupUi(this);
00031 
00032         setWindowTitle(worker->getName());
00033         form.groupBox->setTitle(QString("Control: ")+worker->getName());
00034         this->worker = worker;
00035 
00036         #ifdef PACKAGE_QWT
00037         if (worker->isStatsEnabled()) {
00038                 this->cpuPlot = new QVCpuPlot("Cpu plot of: " + worker->getName(), true, false);
00039                 this->cpuPlot->linkProperty(*worker);
00040                 this->cpuPlot->init();
00041                 connect(form.stat_button, SIGNAL(pressed()),cpuPlot,SLOT(show()));
00042         }
00043         else
00044                 form.stat_button->setEnabled(false);
00045 
00046 /*      this->cpuPlotSmall = new QVCpuPlot("Small cpu plot of: " + worker->getName(), false);
00047         this->cpuPlotSmall->linkProperty(*worker);
00048         this->cpuPlotSmall->setFixedHeight(75);
00049         form.vboxLayout->addWidget(this->cpuPlotSmall);*/
00050         #else
00051         // for now, we don't hide the button.
00052         //form.stat_button.setVisible(false);
00053         #endif
00054 
00055         // Connect worker slots with form's buttons
00056         connect(form.pause_button,SIGNAL(pressed()),worker,SLOT(pause())/*,Qt::QueuedConnection*/);
00057         connect(form.play_button,SIGNAL(pressed()),worker,SLOT(unPause())/*,Qt::QueuedConnection*/);
00058         connect(form.next_button,SIGNAL(pressed()),worker,SLOT(step())/*,Qt::QueuedConnection*/);
00059         connect(form.stop_button, SIGNAL(pressed()),worker,SLOT(finish())/*,Qt::QueuedConnection*/);
00060 
00061         // Connecting slot with worker update signal
00062         connect(worker,SIGNAL(endIteration()),this,SLOT(newIterationSlot()),Qt::QueuedConnection);
00063         connect(worker,SIGNAL(statusUpdate(QVWorker::TWorkerStatus)),
00064                 this,SLOT(statusUpdate(QVWorker::TWorkerStatus))/*,Qt::QueuedConnection*/);
00065 
00066         show();
00067         qDebug() << "QVWorkerInterfaceSmall::QVWorkerInterfaceSmall(" << worker->getName() << ") <- return";
00068         }
00069 
00070 QVWorkerInterfaceSmall::~QVWorkerInterfaceSmall()
00071         {
00072                 if (this->cpuPlot) delete this->cpuPlot;
00073         }
00074 
00075 void QVWorkerInterfaceSmall::newIterationSlot()
00076         { form.iterationsLabel->setText(QString().setNum(worker->getIteration())); }
00077 
00078 void QVWorkerInterfaceSmall::statusUpdate(QVWorker::TWorkerStatus status)
00079         {
00080         switch(status)
00081                 {
00082                 case QVWorker::Finished:
00083                         form.stop_button->setEnabled(FALSE);
00084                         form.pause_button->setEnabled(FALSE);
00085                         form.play_button->setEnabled(FALSE);
00086                         form.next_button->setEnabled(FALSE);
00087                         break;
00088 
00089                 case QVWorker::Running:
00090                         form.pause_button->setEnabled(TRUE);
00091                         form.play_button->setEnabled(FALSE);
00092                         form.next_button->setEnabled(FALSE);
00093                         break;
00094 
00095                 case QVWorker::RunningOneStep:
00096                 case QVWorker::Paused:
00097                         form.pause_button->setEnabled(FALSE);
00098                         form.play_button->setEnabled(TRUE);
00099                         form.next_button->setEnabled(TRUE);
00100                         break;
00101 
00102                 default:
00103                         break;
00104                 }
00105         }
00106