00001 //# PlotMSDrawThread.qo.h: Subclass of PlotMSThread for drawing. 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 PLOTMSDRAWTHREAD_QO_H_ 00028 #define PLOTMSDRAWTHREAD_QO_H_ 00029 00030 #include <plotms/Threads/Gui/PlotMSThread.qo.h> 00031 #include <graphics/GenericPlotter/PlotOperation.h> 00032 #include <vector> 00033 #include <QMutex> 00034 00035 namespace casa { 00036 00037 //# Forward Declarations 00038 class PlotMSPlotter; 00039 class QtProgressWidget; 00040 00041 // Subclass of PlotMSThread that handles following the progress of canvas 00042 // drawing. 00043 class PlotMSDrawThread : public PlotMSThread, public PlotOperationWatcher { 00044 Q_OBJECT 00045 00046 public: 00047 // Constructor which takes the plotter, and optional post-thread method 00048 // parameters. 00049 PlotMSDrawThread(PlotMSPlotter* plotter, QtProgressWidget* progress, 00050 PMSPTMethod postThreadMethod = NULL, 00051 PMSPTObject postThreadObject = NULL); 00052 00053 // Destructor. 00054 ~PlotMSDrawThread(); 00055 00056 00057 // Updates the internal list of canvases based upon the parent 00058 // PlotMSPlotter. 00059 void updatePlotterCanvases(); 00060 00061 // Implements PlotMSThread::startOperation(). 00062 virtual void startOperation(); 00063 00064 bool isDrawing() const; 00065 00066 // Implements PlotOperationWatcher::operationChanged(). 00067 void operationChanged(const PlotOperation& operation); 00068 00069 virtual QString getName() const; 00070 00071 protected: 00072 00073 00074 void cancel(); 00075 00076 private: 00077 PlotMSDrawThread( const PlotMSDrawThread& other ); 00078 PlotMSDrawThread operator=( const PlotMSDrawThread& other ); 00079 PlotMSPlotter* itsPlotter_; 00080 00081 // Operations. 00082 std::vector<PlotOperationPtr> itsOperations_; 00083 00084 // Mutex for accessing operations. 00085 QMutex itsOperationsMutex_; 00086 00087 // Flag for if thread is currently running or not. 00088 bool isRunning_; 00089 00090 // Flag indicating that one or more operations tried to call 00091 // operationChanged() while the operations mutex was locked. 00092 bool itsOperationFlag_; 00093 00094 00095 }; 00096 00097 } 00098 00099 #endif /* PLOTMSDRAWTHREAD_QO_H_ */