casa
$Rev:20696$
|
00001 //# PlotMSExportThread.qo.h: Subclass of PlotMSThread for exporting plots. 00002 //# Copyright (C) 2009 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: $ 00027 #ifndef PLOTMSEXPORTTHREAD_QO_H_ 00028 #define PLOTMSEXPORTTHREAD_QO_H_ 00029 00030 #include <plotms/Actions/PlotMSThread.qo.h> 00031 00032 #include <graphics/GenericPlotter/PlotOptions.h> 00033 00034 #include <QThread> 00035 00036 #include <vector> 00037 00038 #include <casa/namespace.h> 00039 00040 namespace casa { 00041 00042 //# Forward Declarations 00043 class PlotMSExportThreadHelper; 00044 class PlotMSPlot; 00045 00046 00047 // Subclass of PlotMSThread for exporting a plot. 00048 class PlotMSExportThread : public PlotMSThread, public PlotOperationWatcher { 00049 Q_OBJECT 00050 00051 //# Friend class declarations. 00052 friend class PlotMSExportThreadHelper; 00053 00054 public: 00055 // Constructor which takes the plot to export, the export format 00056 // parameters, and optional post-thread method parameters. 00057 PlotMSExportThread( 00058 PlotMSPlot* plot, const PlotExportFormat& format, bool interactive, 00059 PMSPTMethod postThreadMethod = NULL, PMSPTObject postThreadObject = NULL 00060 ); 00061 00062 // Destructor. 00063 ~PlotMSExportThread(); 00064 00065 00066 // Implements PlotMSThread::startOperation(). 00067 void startOperation(); 00068 00069 // Implements PlotOperationWatcher::operationChanged(). 00070 void operationChanged(const PlotOperation& operation); 00071 00072 protected: 00073 // Implements PlotMSThread::wasCanceled(). 00074 bool wasCanceled() const; 00075 00076 protected slots: 00077 // Implements PlotMSThread::background(). Currently is unimplemented. 00078 void background(); 00079 00080 // Implements PlotMSThread::pause(). Currently is unimplemented. 00081 void pause(); 00082 00083 // Implements PlotMSThread::resume(). Currently is unimplemented. 00084 void resume(); 00085 00086 // Implements PlotMSThread::cancel(). Currently is unimplemented. 00087 void cancel(); 00088 00089 private: 00090 // Plot. 00091 PlotMSPlot* itsPlot_; 00092 00093 // Format. 00094 PlotExportFormat itsFormat_; 00095 00096 // Export operations. 00097 vector<PlotOperationPtr> itsOperations_; 00098 00099 // Mutex. 00100 QMutex itsMutex_; 00101 00102 // Helper. 00103 PlotMSExportThreadHelper* itsHelper_; 00104 00105 // Interactive mode? 00106 Bool _interactive; 00107 00108 private slots: 00109 // Slot for when the QThread finishes. 00110 void threadFinished(); 00111 }; 00112 00113 00114 // Helper class for PlotMSExportThread that actually does the work in a new 00115 // QThread. 00116 //class PlotMSExportThreadHelper : public QThread { 00117 class PlotMSExportThreadHelper : public QObject { 00118 Q_OBJECT 00119 00120 //# Friend class declarations. 00121 friend class PlotMSExportThread; 00122 00123 public: 00124 // Constructor that takes parent. 00125 PlotMSExportThreadHelper(PlotMSExportThread* parent); 00126 00127 // Destructor. 00128 ~PlotMSExportThreadHelper(); 00129 00130 protected: 00131 // Implements QThread::run(). 00132 void run(); 00133 00134 private: 00135 // Parent. 00136 PlotMSExportThread* itsParent_; 00137 00138 // Stores the result of the export. 00139 bool itsExportResult_; 00140 00141 signals : 00142 void finished(); 00143 void terminated(); 00144 }; 00145 00146 } 00147 00148 #endif /* PLOTMSEXPORTTHREAD_QO_H_ */