SearchMoleculesWidget.qo.h
Go to the documentation of this file.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
00026 #ifndef SEARCHMOLECULESWIDGET_QO_H_1
00027 #define SEARCHMOLECULESWIDGET_QO_H_1
00028
00029 #include <QtGui/QWidget>
00030 #include <QMap>
00031 #include <QThread>
00032 #include <QProgressDialog>
00033 #include <display/QtPlotter/SearchMoleculesWidget.ui.h>
00034 #include <measures/Measures/MRadialVelocity.h>
00035 #include <measures/Measures/MDoppler.h>
00036 #include <coordinates/Coordinates/SpectralCoordinate.h>
00037 #include <display/QtPlotter/conversion/Converter.h>
00038 #include <spectrallines/Splatalogue/Searcher.h>
00039 #include <spectrallines/Splatalogue/SearcherFactory.h>
00040 #include <display/QtPlotter/SearchMoleculesResultDisplayer.h>
00041 #include <QDebug>
00042
00043 class QTimer;
00044
00045 namespace casa {
00046
00047 class QtCanvas;
00048
00053 class SearchThread : public QThread {
00054 public:
00055 SearchThread( Searcher* searcher, int offset ) {
00056 this->searcher= searcher;
00057 this->offset = offset;
00058 countNeeded = true;
00059 }
00060 String getErrorMessage() const {
00061 return errorMsg;
00062 }
00063 String getErrorMessageCount() const {
00064 return errorMsgCount;
00065 }
00066
00067 void setCountNeeded( bool needed ) {
00068 countNeeded = needed;
00069 }
00070
00071 long getResultsCount() const {
00072 return searchResultsCount;
00073 }
00074
00075 vector<SplatResult> getResults() const {
00076 return searchResults;
00077 }
00078
00079 void stopSearch() {
00080 searcher->stopSearch();
00081 }
00082
00083 void run() {
00084 if ( offset == 0 && countNeeded ) {
00085 searchResultsCount = searcher->doSearchCount( errorMsgCount );
00086 } else {
00087 searchResultsCount = 1;
00088 }
00089 if ( searchResultsCount > 0 ) {
00090 searchResults = searcher->doSearch( errorMsg, offset );
00091 }
00092 }
00093 ~SearchThread() {
00094 }
00095 private:
00096 Searcher* searcher;
00097 int searchResultsCount;
00098 int offset;
00099 bool countNeeded;
00100 vector<SplatResult> searchResults;
00101 string errorMsg;
00102 string errorMsgCount;
00103 };
00104
00105
00106 class SearchMoleculesWidget : public QWidget {
00107 Q_OBJECT
00108
00109 public:
00110 SearchMoleculesWidget(QWidget *parent = 0);
00111 void setCanvas( QtCanvas* drawCanvas );
00112 QString getUnit() const;
00113 bool isLocal() const;
00114
00115 void setRange( double min, double max, QString units );
00116 void setSpectralCoordinate(SpectralCoordinate coord );
00117 void updateReferenceFrame();
00118 static void setInitialReferenceFrame( QString initialReferenceStr );
00119 void setResultDisplay( SearchMoleculesResultDisplayer* resultDisplay );
00120 double getRedShiftedValue( bool reverseRedshift, double value, bool* valid ) const;
00121
00122 vector<SplatResult> getSearchResults() const;
00123 MDoppler::Types getDopplerType() const;
00124 MRadialVelocity::Types getReferenceFrame() const;
00125 MFrequency::Types getReferenceFrequency() const;
00126 ~SearchMoleculesWidget();
00127 static const QString SPLATALOGUE_UNITS;
00128 static const QString SEARCH_DEFAULT_UNITS;
00129
00130 signals:
00131 void searchCompleted();
00132 void redshiftChanged();
00133
00134 private slots:
00135 void search();
00136 void searchUnitsChanged( const QString& searchUnits );
00137 void redshiftChanged( const QString& redshiftStr );
00138 void dopplerShiftChanged();
00139 void dopplerVelocityUnitsChanged();
00140 void searchFinished();
00141 void prevResults();
00142 void nextResults();
00143 void stopSearch();
00144
00145 private:
00146
00147 static QString initialReferenceStr;
00148
00149 void setAstronomicalFilters( Searcher* searcher );
00150 void convertRangeLineEdit( QLineEdit* lineEdit, Converter* converter );
00151 void initializeSearchRange( QLineEdit* lineEdit, Double& value, bool* valid );
00152 vector<string> initializeChemicalNames();
00153 vector<string> initializeChemicalFormulas();
00154 QList<QString> getSearchChemicals();
00155 vector<string> convertStringFormats( const QList<QString>& names );
00156 double redShiftToVelocity( QString velocityUnits) const;
00157 double velocityToRedshift( QString velocityUnits ) const;
00158 void startSearchThread();
00159 void setSearchRangeDefault();
00160 double setRangeValue( double value, QString units );
00161 double getRedShift() const;
00162 MDoppler getRedShiftAdjustment( bool reverseRedshift) const;
00163
00164 enum AstroFilters { NONE, TOP_20, PLANETARY_ATMOSPHERE,HOT_CORES,
00165 DARK_CLOUDS,DIFFUSE_CLOUDS,COMETS, AGB_PPN_PN,EXTRAGALACTIC
00166 };
00167
00168 Ui::SearchMoleculesWidget ui;
00169
00170 QString unitStr;
00171 QString dopplerVelocityUnitStr;
00172 vector<SplatResult> searchResults;
00173 QList<QString> velocityUnitsList;
00174 QMap<QString, MRadialVelocity::Types> radialVelocityTypeMap;
00175 QMap<QString, MDoppler::Types> dopplerTypeMap;
00176 bool dopplerInVelocity;
00177 bool searchInterrupted;
00178 SearchThread* searchThread;
00179 Searcher* searcher;
00180 QtCanvas* canvas;
00181 QProgressDialog progressBar;
00182
00183
00184 SpectralCoordinate coord;
00185
00186
00187 int searchResultCount;
00188 int searchResultOffset;
00189 int searchResultLimit;
00190 static const double SPEED_LIGHT;
00191 static const QString M_PER_SEC;
00192 static const QString KM_PER_SEC;
00193
00194 static const double SPLATALOGUE_DEFAULT_MIN;
00195 static const double SPLATALOGUE_DEFAULT_MAX;
00196 SearchMoleculesResultDisplayer* resultDisplay;
00197 };
00198
00199 }
00200
00201 #endif // SEARCHMOLECULESWIDGET_H