00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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 <coordinates/Coordinates/SpectralCoordinate.h>
00034 #include <display/QtPlotter/ProfileTaskFacilitator.h>
00035 #include <display/QtPlotter/MomentSettingsWidgetRadio.ui.h>
00036 #include <imageanalysis/ImageAnalysis/ImageMomentsProgressMonitor.h>
00037
00038 namespace casa {
00039
00040 class MomentCollapseThreadRadio;
00041 class ThresholdingBinPlotDialog;
00042 class Converter;
00043 template <class T> class ImageMoments;
00044 template <class T> class ImageInterface;
00045
00046 class CollapseResult {
00047
00048 public:
00049 CollapseResult( const String& outputName, bool tmp, SHARED_PTR<ImageInterface<Float>> img );
00050
00051 String getOutputFileName() const {
00052 return outputFileName;
00053 }
00054 bool isTemporaryOutput() const {
00055 return temporary;
00056 }
00057 SHARED_PTR<ImageInterface<Float> > getImage() const {
00058 return image;
00059 }
00060
00061 private:
00062 String outputFileName;
00063 bool temporary;
00064
00065 SHARED_PTR<ImageInterface<Float> > image;
00066 };
00067
00068
00069
00070
00071
00076 class MomentCollapseThreadRadio : public QThread, public ImageMomentsProgressMonitor {
00077 Q_OBJECT
00078 public:
00079 MomentCollapseThreadRadio( ImageMoments<Float>* imageAnalysis );
00080 bool isSuccess() const;
00081 void setChannelStr( String str );
00082 void setMomentNames( const Vector<QString>& momentNames );
00083 void setOutputFileName( QString name );
00084 String getErrorMessage() const;
00085 std::vector<CollapseResult> getResults() const;
00086 void setData(const Vector<Int>& moments, const Int axis,
00087 const Vector<String>& method,
00088 const Vector<Int>& smoothaxes,
00089 const Vector<String>& smoothtypes,
00090 const Vector<Quantity>& smoothwidths,
00091 const Vector<Float>& includepix,
00092 const Vector<Float>& excludepix,
00093 const Double peaksnr, const Double stddev,
00094 const String& doppler = "RADIO", const String& baseName = "");
00095 void run();
00096 void halt();
00097
00098 void setStepCount( int count );
00099 void setStepsCompleted( int count );
00100 void done();
00101 ~MomentCollapseThreadRadio();
00102
00103 signals:
00104 void stepCountChanged( int count );
00105 void stepsCompletedChanged( int count );
00106
00107 private:
00108 bool getOutputFileName( String& outName, int moment, const String& channelStr ) const;
00109
00110 ImageMoments<Float>* analysis;
00111 Vector<Int> moments;
00112 Vector<QString> momentNames;
00113 Int axis;
00114 String channelStr;
00115 Vector<String> method;
00116 Vector<Int> smoothaxes;
00117 Vector<String> smoothtypes;
00118 Vector<Quantity> smoothwidths;
00119 Vector<Float> includepix;
00120 Vector<Float> excludepix;
00121 Double peaksnr;
00122 Double stddev;
00123 String doppler;
00124 String baseName;
00125 QString outputFileName;
00126 int stepSize;
00127 std::vector<CollapseResult> collapseResults;
00128 String errorMsg;
00129 bool collapseError;
00130 bool stopImmediately;
00131 };
00132
00133
00134
00135
00136
00137
00138 class MomentSettingsWidgetRadio : public QWidget, public ProfileTaskFacilitator {
00139 Q_OBJECT
00140
00141 public:
00142 MomentSettingsWidgetRadio(QWidget *parent = 0);
00143
00144 void setUnits( QString units );
00145 void setRange( double min, double max );
00146 void reset();
00147 ~MomentSettingsWidgetRadio();
00148
00149 signals:
00150 void updateProgress(int);
00151 void momentsFinished();
00152
00153 private slots:
00154 void setStepCount( int count );
00155 void setStepsCompleted( int count );
00156 void thresholdingChanged();
00157 void thresholdSpecified();
00158 void adjustTableRows( int count );
00159 void collapseImage();
00160 void setCollapsedImageFile();
00161 void collapseDone();
00162 void graphicalThreshold();
00163 void symmetricThresholdChanged( int checkedState );
00164 void thresholdTextChanged( const QString& text );
00165 void stopMoments();
00166
00167 private:
00168 void _initAnalysis();
00169 Record _makeRegionRecord( );
00170 enum SummationIndex {MEAN, INTEGRATED, WEIGHTED_MEAN, DISPERSION, MEDIAN,
00171 MEDIAN_VELOCITY, STDDEV, RMS, ABS_MEAN_DEV, MAX, MAX_VELOCITY, MIN,
00172 MIN_VELOCITY, END_INDEX
00173 };
00174 QMap<SummationIndex, int> momentMap;
00175 Ui::MomentSettingsWidgetRadio ui;
00176 ImageMoments<Float>* imageAnalysis;
00177 MomentCollapseThreadRadio* collapseThread;
00178 ThresholdingBinPlotDialog* thresholdingBinDialog;
00179 QString outputFileName;
00180 QList<QString> momentOptions;
00181 QProgressDialog progressBar;
00182 QString m_units;
00183
00184
00185 int momentCount;
00186 int cycleCount;
00187 int baseIncrement;
00188 int previousCount;
00189
00190 void setTableValue(int row, int col, float val );
00191 void getChannelMinMax( int channelIndex, QString& minStr, QString& maxStr ) const;
00192 void convertChannelRanges( const QString& oldUnits, const QString& newUnits );
00193 void convertChannelValue( const QString& channelStr, const QString& channelIdentifier,
00194 Converter* converter, int row, int col, bool toPixels,
00195 SpectralCoordinate& coord );
00196 String makeChannelInterval( float startChannelIndex,float endChannelIndex ) const;
00197 Vector<Int> populateMoments( Vector<QString>& momentNames );
00198 Vector<String> populateMethod() const;
00199 String populateChannels(uInt * nSelectedChannels, bool * channelOK);
00200 bool populateThresholds( Vector<Float>& includeThreshold, Vector<Float>& excludeThreshold );
00201 bool populateThreshold( Vector<Float>& threshold );
00202 };
00203
00204 }
00205
00206 #endif // MOMENTSETTINGSWIDGETRADIO_QO_H