MomentSettingsWidgetRadio.qo.h

Go to the documentation of this file.
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 <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 //Note:  ImageMomentsProgressMonitor is an interface that provides this class
00070 //with updates concerning the progress of the moment calculation task.
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                 //Methods from the ImageMomentsProgressMonitor interface
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 //Note: ProfileTaskFacilitator abstracts out some of the common functionality
00134 //needed for calculating moments and spectral line fitting into a single
00135 //base class
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                 //Progress Monitor functionality
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
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1