PARP Research Group University of Murcia, Spain


src/qvgui/qvworkerinterfacesmall.cpp

Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2007, 2008, 2009. 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(worker->getName());
00034         this->worker = worker;
00035         isGroupMaster = worker->isSequentialGroupMaster();
00036 
00037         if (worker->isStatsEnabled()) {
00038                 this->cpuPlot = new QVCPUPlot("CPU performance plot of: " + worker->getName(), true, false);
00039                 worker->linkProperty("cpu stats", this->cpuPlot);
00040                 this->cpuPlot->init();
00041                 connect(form.stat_button,SIGNAL(toggled(bool)),cpuPlot,SLOT(setVisible(bool)));
00042                 connect(cpuPlot,SIGNAL(closed()),form.stat_button,SLOT(toggle()));
00043         }
00044         else
00045                 form.stat_button->setEnabled(false);
00046 
00047 /*      this->cpuPlotSmall = new QVCPUPlot("Small cpu plot of: " + worker->getName(), false);
00048         this->cpuPlotSmall->linkProperty(*worker);
00049         this->cpuPlotSmall->setFixedHeight(75);
00050         form.vboxLayout->addWidget(this->cpuPlotSmall);*/
00051 
00052         // Connect worker slots with form's buttons
00053         connect(form.pause_button,SIGNAL(pressed()),worker,SLOT(pause()),Qt::QueuedConnection);
00054         connect(form.play_button,SIGNAL(pressed()),worker,SLOT(unPause()),Qt::QueuedConnection);
00055         connect(form.next_button,SIGNAL(pressed()),worker,SLOT(step()),Qt::QueuedConnection);
00056         connect(form.stop_button, SIGNAL(pressed()),worker,SLOT(stop()),Qt::QueuedConnection);
00057         connect(form.finish_button, SIGNAL(pressed()),this,SLOT(finishWorker()),Qt::QueuedConnection);
00058 
00059         // Connecting slot with worker update signal
00060         connect(worker,SIGNAL(endIteration(uint, int)),this,SLOT(newIterationSlot()),Qt::QueuedConnection);
00061         connect(worker,SIGNAL(statusUpdate(QVWorker::TWorkerStatus)),
00062                 this,SLOT(statusUpdate(QVWorker::TWorkerStatus)),Qt::QueuedConnection);
00063 
00064         statusUpdate(worker->getStatus());
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::finishWorker()
00076         {
00077                 qvApp->quitWorker(worker);
00078         }
00079 
00080 void QVWorkerInterfaceSmall::newIterationSlot()
00081         { form.iterationsLabel->setText(QString("Iteration: ")+QString().setNum(worker->getIteration())); }
00082 
00083 void QVWorkerInterfaceSmall::statusUpdate(QVWorker::TWorkerStatus status)
00084         {
00085         isGroupMaster = worker->isSequentialGroupMaster();
00086         if (!isGroupMaster) {
00087                 form.finish_button->setEnabled(FALSE);
00088                 form.stop_button->setEnabled(FALSE);
00089                 form.pause_button->setEnabled(FALSE);
00090                 form.play_button->setEnabled(FALSE);
00091                 form.next_button->setEnabled(FALSE);
00092                 }
00093         else {
00094                 switch(status)
00095                         {
00096                         case QVWorker::Finished:
00097                                 form.finish_button->setEnabled(FALSE);
00098                                 form.stop_button->setEnabled(FALSE);
00099                                 form.pause_button->setEnabled(FALSE);
00100                                 form.play_button->setEnabled(FALSE);
00101                                 form.next_button->setEnabled(FALSE);
00102                                 break;
00103         
00104                         case QVWorker::Stoped:
00105                                 form.finish_button->setEnabled(TRUE);
00106                                 form.stop_button->setEnabled(FALSE);
00107                                 form.pause_button->setEnabled(FALSE);
00108                                 form.play_button->setEnabled(FALSE);
00109                                 form.next_button->setEnabled(FALSE);
00110                                 break;
00111         
00112                         case QVWorker::Running:
00113                                 form.finish_button->setEnabled(TRUE);
00114                                 form.stop_button->setEnabled(TRUE);
00115                                 form.pause_button->setEnabled(TRUE);
00116                                 form.play_button->setEnabled(FALSE);
00117                                 form.next_button->setEnabled(FALSE);
00118                                 break;
00119         
00120                         case QVWorker::RunningOneStep:
00121                         case QVWorker::Paused:
00122                                 form.finish_button->setEnabled(TRUE);
00123                                 form.stop_button->setEnabled(TRUE);
00124                                 form.pause_button->setEnabled(FALSE);
00125                                 form.play_button->setEnabled(TRUE);
00126                                 form.next_button->setEnabled(TRUE);
00127                                 break;
00128         
00129                         default:
00130                                 break;
00131                         }
00132                 }
00133         }
00134 



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