process.cc

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                              OpenFlipper                                  *
00004  *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openflipper.org                             *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenFlipper.                                        *
00009  *                                                                           *
00010  *  OpenFlipper is free software: you can redistribute it and/or modify      *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenFlipper is distributed in the hope that it will be useful,           *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenFlipper. If not,                                  *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 83 $                                                         *
00038  *   $Author: moebius $                                                      *
00039  *   $Date: 2009-02-27 17:31:45 +0100 (Fr, 27. Feb 2009) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 
00045 
00046 //=============================================================================
00047 //
00048 //  CLASS Core - IMPLEMENTATION
00049 //
00050 //=============================================================================
00051 
00052 
00053 //== INCLUDES =================================================================
00054 
00055 #include "Core.hh"
00056 
00057 //== IMPLEMENTATION ==========================================================
00058 
00059 
00060 // A job has been started by a plugin
00061 void Core::slotStartJob( QString _jobId, QString _description , int _min , int _max, bool _blocking) {
00062   std::cerr << "StartJob: " << _jobId.toStdString() << " " << _description.toStdString() << " " << _min << " " << _max  << " " << _blocking <<std::endl;
00063   
00064   JobInfo* info        = new JobInfo();
00065   info->jobId          = _jobId;
00066   info->description    = _description;
00067   info->min            = _min;
00068   info->max            = _max;
00069   info->blocking       = _blocking;
00070   info->progressDialog = new QProgressDialog(coreWidget_);
00071   info->progressDialog->setLabelText(_description);
00072   info->progressDialog->setMinimum(_min);
00073   info->progressDialog->setMaximum(_max);
00074   info->progressDialog->setValue(_min);
00075   info->progressDialog->resize(300,130);
00076   info->progressDialog->setMinimumDuration(1);
00077   if ( _blocking )
00078     info->progressDialog->setWindowModality(Qt::WindowModal);
00079   
00080   connect( info->progressDialog, SIGNAL(canceled()),
00081            this,SLOT(slotJobCancelButtons()));
00082   
00083   currentJobs.push_back(info);
00084   
00085 }
00086 
00087 //-----------------------------------------------------------------------------
00088 bool Core::getJob(QString _jobId, int& _index) {
00089   
00090   for ( int i = 0 ; i < currentJobs.size() ; ++i) {
00091       if ( currentJobs[i]->jobId == _jobId ) {
00092         _index = i;
00093         return true;
00094       }
00095   }
00096   
00097   emit log(LOGERR,tr("Unable to find Job %1.").arg(_jobId));
00098   _index = -1;
00099   return false;
00100 }
00101 
00102 //-----------------------------------------------------------------------------
00103 
00104 // A job state has been updated by a plugin
00105 void Core::slotSetJobState(QString _jobId, int _value ) {
00106   int id;
00107   
00108   if (  getJob(_jobId, id) ) {
00109     currentJobs[id]->currentState = _value;
00110     currentJobs[id]->progressDialog->setValue(_value);
00111   }
00112 }
00113 
00114 //-----------------------------------------------------------------------------
00115 
00116 // A job state has been canceled by a plugin
00117 void Core::slotCancelJob(QString _jobId ) {
00118   int id;
00119   
00120   if (  getJob(_jobId, id) ) {
00121     currentJobs[id]->progressDialog->reset();
00122     currentJobs[id]->progressDialog->hide();
00123     delete currentJobs[id]->progressDialog;
00124     currentJobs.removeAt(id);
00125   }
00126 }
00127 
00128 //-----------------------------------------------------------------------------
00129 
00130 // A job state has been finished by a plugin
00131 void Core::slotFinishJob(QString _jobId ) {
00132   int id;
00133   
00134   if (  getJob(_jobId, id) ) {
00135     currentJobs[id]->progressDialog->reset();
00136     currentJobs[id]->progressDialog->hide();
00137     delete currentJobs[id]->progressDialog;
00138     currentJobs.removeAt(id);
00139   }
00140 }
00141 
00142 // The user canceled a job
00143 void Core::slotJobCancelButtons( ) {
00144   for ( int i = 0 ; i < currentJobs.size() ; ++i) {
00145     if ( currentJobs[i]->progressDialog == sender() ) {
00146       QString id = currentJobs[i]->jobId;
00147       slotCancelJob(id);
00148       emit jobCanceled( id );
00149     }
00150   }
00151 }
00152 
00153 
00154 
00155 
00156 //=============================================================================

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .