threads.h

Go to the documentation of this file.
00001 #ifndef BALL_VIEW_KERNEL_THREADS_H
00002 #define BALL_VIEW_KERNEL_THREADS_H
00003 
00004 #ifndef BALL_VIEW_KERNEL_COMMON_H_
00005 #include <BALL/VIEW/KERNEL/common.h>
00006 #endif
00007 
00008 #ifndef BALL_SYSTEM_TCPTRANSFER
00009 # include <BALL/SYSTEM/TCPTransfer.h>
00010 #endif
00011 
00012 #include <QtCore/QThread>
00013 #include <QtCore/QEvent>
00014 
00015 namespace BALL
00016 {
00017   class EnergyMinimizer;
00018   class MolecularDynamics;
00019   class Composite;
00020   class DockingAlgorithm;
00021   class DCDFile;
00022 
00023 namespace VIEW
00024 {
00025   class MainControl;
00026   class FDPBDialog;
00027   class Message;
00028   class Representation;
00029 
00034   class BALL_VIEW_EXPORT MessageEvent
00035     : public QEvent
00036   {
00037     public:
00038 
00040     MessageEvent(Message* msg = 0)
00041     : QEvent((QEvent::Type)MESSAGE_EVENT),
00042       message_(msg)
00043     {}
00044 
00046     void setMessage(Message* msg) { message_ = msg; }
00047 
00049     Message* getMessage() { return message_; }
00050 
00051     protected:
00052 
00053     Message* message_;
00054   };
00055 
00056 
00073   class BALL_VIEW_EXPORT BALLThread
00074     : public virtual QThread
00075   {
00076     public:
00077 
00079       BALLThread();
00080       
00082       void setMainControl(MainControl* mf) {main_control_ = mf;}
00083       
00085       void setComposite(Composite* composite) {composite_ = composite;}
00086 
00088       Composite* getComposite() { return composite_;}
00089   
00092       virtual void run() {};
00093       
00094       protected:
00095 
00099       void sendMessage_(Message* msg);
00100 
00107       void updateStructure_();
00108 
00110       void output_(const String& string, bool important = false);
00111 
00116       void waitForUpdateOfRepresentations_();
00117   
00118       MainControl*  main_control_;
00119       Composite*    composite_;
00120     };
00121 
00122   
00127   class BALL_VIEW_EXPORT FetchHTMLThread
00128     : public BALLThread
00129   {
00130     public:
00132       FetchHTMLThread();
00133 
00135       void setURL(const String& text);
00136 
00138       virtual void run();
00139 
00141       virtual void abort() { tcp_.abort();}
00142 
00144       void setFilename(const String& file_name) { file_name_ = file_name;}
00145 
00147       const String& getFilename() const { return file_name_;}
00148 
00150       TCPTransfer& getTCPTransfer() { return tcp_;}
00151 
00153       std::stringstream& getStream() { return stream_;}
00154 
00155       protected:
00156       String url_;
00157       String file_name_;
00158       TCPTransfer tcp_;
00159       std::stringstream stream_;
00160   };
00161   
00163   class BALL_VIEW_EXPORT CalculateFDPBThread
00164     : public BALLThread
00165   {
00166     public:
00167 
00169       CalculateFDPBThread();
00170 
00172       virtual void run();
00173 
00175       void setFDPBDialog(FDPBDialog* dialog) {dialog_ = dialog;}
00176 
00177     protected:
00178       FDPBDialog* dialog_;
00179   };
00180 
00181 
00183   class BALL_VIEW_EXPORT UpdateRepresentationThread
00184     : public BALLThread
00185   {
00186     public:
00187 
00189       UpdateRepresentationThread();
00190 
00192       virtual void run();
00193 
00195       void setRepresentation(Representation& rep)
00196         { rep_ = &rep;}
00197 
00199       Representation* getRepresentation()
00200         { return rep_; }
00201 
00202     protected:
00203 
00204       Representation* rep_;
00205   };
00206 
00207 
00213   class BALL_VIEW_EXPORT SimulationThread
00214     : public BALLThread
00215   {
00216     public:
00217 
00219       SimulationThread();
00220 
00222       void setNumberOfStepsBetweenUpdates(Size steps)
00223         { steps_between_updates_ = steps;}
00224 
00226       void setDCDFile(DCDFile* file) {dcd_file_ = file;}
00227 
00229       DCDFile* getDCDFile() { return dcd_file_;}
00230 
00231       protected:
00232   
00234       void exportSceneToPNG_();
00235 
00237       void finish_();
00238 
00239       Size          steps_between_updates_;
00240       DCDFile*      dcd_file_;
00241     };
00242 
00243 
00245     class BALL_VIEW_EXPORT EnergyMinimizerThread
00246       : public SimulationThread
00247     {
00248       public:
00249 
00251         EnergyMinimizerThread();
00252         
00254         virtual ~EnergyMinimizerThread();
00255         
00257         virtual void run();
00258 
00260         void setEnergyMinimizer(EnergyMinimizer* minimizer);
00261 
00262       protected:
00263         EnergyMinimizer* minimizer_;
00264     };
00265 
00266 
00268     class BALL_VIEW_EXPORT MDSimulationThread
00269       : public SimulationThread
00270     {
00271       public:
00272 
00274         MDSimulationThread();
00275         
00277         virtual ~MDSimulationThread();
00278         
00280         virtual void run()
00281           throw(Exception::NullPointer);
00282 
00284         void setMolecularDynamics(MolecularDynamics* md);
00285 
00287         void setNumberOfSteps(Size steps) { steps_ = steps;}
00288 
00290         void setSaveImages(bool state) { save_images_ = state;}
00291 
00292       protected:
00293         MolecularDynamics* md_;
00294         Size steps_;
00295         bool save_images_;
00296     };
00297 
00298 
00300     class BALL_VIEW_EXPORT DockingThread
00301       : public BALLThread
00302     {
00303       public:
00305         DockingThread();
00306         
00309         DockingThread(const DockingThread& dock_thread);
00310           
00312         virtual ~DockingThread();
00313         
00316         const DockingThread& operator =(const DockingThread& dock_thread);
00317           
00319         void setDockingAlgorithm(DockingAlgorithm* dock_alg);
00320           
00322         virtual void run()
00323           throw(Exception::NullPointer);
00324           
00325       protected:
00326         DockingAlgorithm* dock_alg_;
00327     };
00328   
00329   }
00330 }
00331 #endif //BALL_VIEW_KERNEL_THREADS_H