casa
$Rev:20696$
|
00001 //# Copyright (C) 2005 00002 //# Associated Universities, Inc. Washington DC, USA. 00003 //# 00004 //# This library is free software; you can redistribute it and/or modify it 00005 //# under the terms of the GNU Library General Public License as published by 00006 //# the Free Software Foundation; either version 2 of the License, or (at your 00007 //# option) any later version. 00008 //# 00009 //# This library is distributed in the hope that it will be useful, but WITHOUT 00010 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 //# License for more details. 00013 //# 00014 //# You should have received a copy of the GNU Library General Public License 00015 //# along with this library; if not, write to the Free Software Foundation, 00016 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00017 //# 00018 //# Correspondence concerning AIPS++ should be addressed as follows: 00019 //# Internet email: aips2-request@nrao.edu. 00020 //# Postal address: AIPS++ Project Office 00021 //# National Radio Astronomy Observatory 00022 //# 520 Edgemont Road 00023 //# Charlottesville, VA 22903-2475 USA 00024 //# 00025 #ifndef MOMENTSETTINGSWIDGETRADIO_QO_H 00026 #define MOMENTSETTINGSWIDGETRADIO_QO_H 00027 00028 #include <QtGui/QWidget> 00029 #include <QMap> 00030 #include <QThread> 00031 #include <QProgressDialog> 00032 #include <casa/Quanta/Quantum.h> 00033 #include <display/QtPlotter/ProfileTaskFacilitator.h> 00034 #include <display/QtPlotter/MomentSettingsWidgetRadio.ui.h> 00035 #include <imageanalysis/ImageAnalysis/ImageMomentsProgressMonitor.h> 00036 00037 namespace casa { 00038 00039 class ImageAnalysis; 00040 class MomentCollapseThreadRadio; 00041 class ThresholdingBinPlotDialog; 00042 class Converter; 00043 template <class T> class ImageInterface; 00044 00045 class CollapseResult { 00046 00047 public: 00048 CollapseResult( const String& outputName, bool tmp, ImageInterface<Float>* img ): 00049 outputFileName(outputName), 00050 temporary( tmp ), 00051 image(img) {} 00052 String getOutputFileName() const { return outputFileName; } 00053 bool isTemporaryOutput() const { return temporary; } 00054 ImageInterface<Float>* getImage() const { return image; } 00055 00056 private: 00057 String outputFileName; 00058 bool temporary; 00059 ImageInterface<Float>* image; 00060 }; 00061 00062 00063 //Note: ImageMomentsProgressMonitor is an interface that provides this class 00064 //with updates concerning the progress of the moment calculation task. 00065 00070 class MomentCollapseThreadRadio : public QThread, public ImageMomentsProgressMonitor { 00071 Q_OBJECT 00072 public: 00073 MomentCollapseThreadRadio( ImageAnalysis* imageAnalysis ); 00074 bool isSuccess() const; 00075 void setChannelStr( String str ); 00076 void setMomentNames( const Vector<QString>& momentNames ); 00077 void setOutputFileName( QString name ); 00078 String getErrorMessage() const; 00079 std::vector<CollapseResult> getResults() const; 00080 void setData(const Vector<Int>& moments, const Int axis, Record& region, 00081 const String& mask, const Vector<String>& method, 00082 const Vector<Int>& smoothaxes, 00083 const Vector<String>& smoothtypes, 00084 const Vector<Quantity>& smoothwidths, 00085 const Vector<Float>& includepix, 00086 const Vector<Float>& excludepix, 00087 const Double peaksnr, const Double stddev, 00088 const String& doppler = "RADIO", const String& baseName = ""); 00089 void run(); 00090 00091 //Methods from the ImageMomentsProgressMonitor interface 00092 void setStepCount( int count ); 00093 void setStepsCompleted( int count ); 00094 void done(); 00095 ~MomentCollapseThreadRadio(); 00096 00097 signals: 00098 void stepCountChanged( int count ); 00099 void stepsCompletedChanged( int count ); 00100 00101 private: 00102 bool getOutputFileName( String& outName, int moment, const String& channelStr ) const; 00103 ImageAnalysis* analysis; 00104 Vector<Int> moments; 00105 Vector<QString> momentNames; 00106 Int axis; 00107 Record region; 00108 String mask; 00109 String channelStr; 00110 Vector<String> method; 00111 Vector<Int> smoothaxes; 00112 Vector<String> smoothtypes; 00113 Vector<Quantity> smoothwidths; 00114 Vector<Float> includepix; 00115 Vector<Float> excludepix; 00116 Double peaksnr; 00117 Double stddev; 00118 String doppler; 00119 String baseName; 00120 QString outputFileName; 00121 int stepSize; 00122 std::vector<CollapseResult> collapseResults; 00123 String errorMsg; 00124 bool collapseError; 00125 }; 00126 00127 //Note: ProfileTaskFacilitator abstracts out some of the common functionality 00128 //needed for calculating moments and spectral line fitting into a single 00129 //base class 00130 00131 00132 class MomentSettingsWidgetRadio : public QWidget, public ProfileTaskFacilitator{ 00133 Q_OBJECT 00134 00135 public: 00136 MomentSettingsWidgetRadio(QWidget *parent = 0); 00137 00138 void setUnits( QString units ); 00139 void setRange( double min, double max ); 00140 void reset(); 00141 ~MomentSettingsWidgetRadio(); 00142 00143 signals: 00144 void updateProgress(int); 00145 void momentsFinished(); 00146 00147 private slots: 00148 void setStepCount( int count ); 00149 void setStepsCompleted( int count ); 00150 void thresholdingChanged(); 00151 void thresholdSpecified(); 00152 void adjustTableRows( int count ); 00153 void collapseImage(); 00154 void setCollapsedImageFile(); 00155 void collapseDone(); 00156 void graphicalThreshold(); 00157 void symmetricThresholdChanged( int checkedState ); 00158 void thresholdTextChanged( const QString& text ); 00159 00160 private: 00161 enum SummationIndex {MEAN, INTEGRATED, WEIGHTED_MEAN, DISPERSION, MEDIAN, 00162 MEDIAN_VELOCITY, STDDEV, RMS, ABS_MEAN_DEV, MAX, MAX_VELOCITY, MIN, 00163 MIN_VELOCITY, END_INDEX}; 00164 QMap<SummationIndex, int> momentMap; 00165 Ui::MomentSettingsWidgetRadio ui; 00166 ImageAnalysis* imageAnalysis; 00167 MomentCollapseThreadRadio* collapseThread; 00168 ThresholdingBinPlotDialog* thresholdingBinDialog; 00169 QString outputFileName; 00170 QList<QString> momentOptions; 00171 QProgressDialog progressBar; 00172 00173 //Progress Monitor functionality 00174 int momentCount; 00175 int cycleCount; 00176 int baseIncrement; 00177 int previousCount; 00178 00179 void setTableValue(int row, int col, float val ); 00180 void getChannelMinMax( int channelIndex, QString& minStr, QString& maxStr ) const; 00181 void convertChannelRanges( const QString& oldUnits, const QString& newUnits ); 00182 void convertChannelValue( const QString& channelStr, const QString& channelIdentifier, 00183 Converter* converter, int row, int col, bool toPixels ); 00184 String makeChannelInterval( float startChannelIndex,float endChannelIndex ) const; 00185 Vector<Int> populateMoments( Vector<QString>& momentNames ); 00186 Vector<String> populateMethod() const; 00187 String populateChannels(uInt * nSelectedChannels); 00188 bool populateThresholds( Vector<Float>& includeThreshold, Vector<Float>& excludeThreshold ); 00189 bool populateThreshold( Vector<Float>& threshold ); 00190 }; 00191 00192 } 00193 00194 #endif // MOMENTSETTINGSWIDGETRADIO_QO_H