PARP Research Group University of Murcia, Spain


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(worker->getName());
00034         this->worker = worker;
00035         isGroupMaster = worker->isSequentialGroupMaster();
00036 
00037         #ifdef PACKAGE_QWT
00038         if (worker->isStatsEnabled()) {
00039                 this->cpuPlot = new QVCPUPlot("CPU performance plot of: " + worker->getName(), true, false);
00040                 worker->linkProperty("cpu stats", this->cpuPlot);
00041                 this->cpuPlot->init();
00042                 connect(form.stat_button, SIGNAL(pressed()),cpuPlot,SLOT(show()));
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         #else
00052         // for now, we don't hide the button.
00053         //form.stat_button.setVisible(false);
00054         #endif
00055 
00056         // Connect worker slots with form's buttons
00057         connect(form.pause_button,SIGNAL(pressed()),worker,SLOT(pause()),Qt::QueuedConnection);
00058         connect(form.play_button,SIGNAL(pressed()),worker,SLOT(unPause()),Qt::QueuedConnection);
00059         connect(form.next_button,SIGNAL(pressed()),worker,SLOT(step()),Qt::QueuedConnection);
00060         connect(form.stop_button, SIGNAL(pressed()),worker,SLOT(stop()),Qt::QueuedConnection);
00061         connect(form.finish_button, SIGNAL(pressed()),this,SLOT(finishWorker()),Qt::QueuedConnection);
00062 
00063         // Connecting slot with worker update signal
00064         connect(worker,SIGNAL(endIteration(uint, int)),this,SLOT(newIterationSlot()),Qt::QueuedConnection);
00065         connect(worker,SIGNAL(statusUpdate(QVWorker::TWorkerStatus)),
00066                 this,SLOT(statusUpdate(QVWorker::TWorkerStatus)),Qt::QueuedConnection);
00067 
00068         statusUpdate(worker->getStatus());
00069 
00070         show();
00071         qDebug() << "QVWorkerInterfaceSmall::QVWorkerInterfaceSmall(" << worker->getName() << ") <- return";
00072         }
00073 
00074 QVWorkerInterfaceSmall::~QVWorkerInterfaceSmall()
00075         {
00076                 if (this->cpuPlot) delete this->cpuPlot;
00077         }
00078 
00079 void QVWorkerInterfaceSmall::finishWorker()
00080         {
00081                 qvApp->quitWorker(worker);
00082         }
00083 
00084 void QVWorkerInterfaceSmall::newIterationSlot()
00085         { form.iterationsLabel->setText(QString().setNum(worker->getIteration())); }
00086 
00087 void QVWorkerInterfaceSmall::statusUpdate(QVWorker::TWorkerStatus status)
00088         {
00089         isGroupMaster = worker->isSequentialGroupMaster();
00090         if (!isGroupMaster) {
00091                 form.finish_button->setEnabled(FALSE);
00092                 form.stop_button->setEnabled(FALSE);
00093                 form.pause_button->setEnabled(FALSE);
00094                 form.play_button->setEnabled(FALSE);
00095                 form.next_button->setEnabled(FALSE);
00096                 }
00097         else {
00098                 switch(status)
00099                         {
00100                         case QVWorker::Finished:
00101                                 form.finish_button->setEnabled(FALSE);
00102                                 form.stop_button->setEnabled(FALSE);
00103                                 form.pause_button->setEnabled(FALSE);
00104                                 form.play_button->setEnabled(FALSE);
00105                                 form.next_button->setEnabled(FALSE);
00106                                 break;
00107         
00108                         case QVWorker::Stoped:
00109                                 form.finish_button->setEnabled(TRUE);
00110                                 form.stop_button->setEnabled(FALSE);
00111                                 form.pause_button->setEnabled(FALSE);
00112                                 form.play_button->setEnabled(FALSE);
00113                                 form.next_button->setEnabled(FALSE);
00114                                 break;
00115         
00116                         case QVWorker::Running:
00117                                 form.finish_button->setEnabled(TRUE);
00118                                 form.stop_button->setEnabled(TRUE);
00119                                 form.pause_button->setEnabled(TRUE);
00120                                 form.play_button->setEnabled(FALSE);
00121                                 form.next_button->setEnabled(FALSE);
00122                                 break;
00123         
00124                         case QVWorker::RunningOneStep:
00125                         case QVWorker::Paused:
00126                                 form.finish_button->setEnabled(TRUE);
00127                                 form.stop_button->setEnabled(TRUE);
00128                                 form.pause_button->setEnabled(FALSE);
00129                                 form.play_button->setEnabled(TRUE);
00130                                 form.next_button->setEnabled(TRUE);
00131                                 break;
00132         
00133                         default:
00134                                 break;
00135                         }
00136                 }
00137         }
00138 



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