casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SearchMoleculesWidget.qo.h
Go to the documentation of this file.
1 //# Copyright (C) 2005
2 //# Associated Universities, Inc. Washington DC, USA.
3 //#
4 //# This library is free software; you can redistribute it and/or modify it
5 //# under the terms of the GNU Library General Public License as published by
6 //# the Free Software Foundation; either version 2 of the License, or (at your
7 //# option) any later version.
8 //#
9 //# This library is distributed in the hope that it will be useful, but WITHOUT
10 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 //# License for more details.
13 //#
14 //# You should have received a copy of the GNU Library General Public License
15 //# along with this library; if not, write to the Free Software Foundation,
16 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
17 //#
18 //# Correspondence concerning AIPS++ should be addressed as follows:
19 //# Internet email: aips2-request@nrao.edu.
20 //# Postal address: AIPS++ Project Office
21 //# National Radio Astronomy Observatory
22 //# 520 Edgemont Road
23 //# Charlottesville, VA 22903-2475 USA
24 //#
25 
26 #ifndef SEARCHMOLECULESWIDGET_QO_H_1
27 #define SEARCHMOLECULESWIDGET_QO_H_1
28 
29 #include <QWidget>
30 #include <QMap>
31 #include <QThread>
32 #include <QProgressDialog>
33 #include <display/QtPlotter/SearchMoleculesWidget.ui.h>
41 #include <QDebug>
42 
43 class QTimer;
44 
45 namespace casa {
46 
47  class QtCanvas;
48 
53  class SearchThread : public QThread {
54  public:
56  this->searcher= searcher;
57  this->offset = offset;
58  countNeeded = true;
59  }
61  return errorMsg;
62  }
64  return errorMsgCount;
65  }
66 
67  void setCountNeeded( bool needed ) {
68  countNeeded = needed;
69  }
70 
71  long getResultsCount() const {
72  return searchResultsCount;
73  }
74 
75  std::vector<SplatResult> getResults() const {
76  return searchResults;
77  }
78 
79  void stopSearch() {
81  }
82 
83  void run() {
84  if ( offset == 0 && countNeeded ) {
86  } else {
88  }
89  if ( searchResultsCount > 0 ) {
91  }
92  }
94  }
95  private:
98  int offset;
100  std::vector<SplatResult> searchResults;
101  string errorMsg;
103  };
104 
105 
106  class SearchMoleculesWidget : public QWidget {
107  Q_OBJECT
108 
109  public:
110  SearchMoleculesWidget(QWidget *parent = 0);
111  void setCanvas( QtCanvas* drawCanvas );
112  QString getUnit() const;
113  bool isLocal() const;
114 
115  void setRange( double min, double max, QString units );
117  void updateReferenceFrame();
118  static void setInitialReferenceFrame( QString initialReferenceStr );
120  double getRedShiftedValue( bool reverseRedshift, double value, bool* valid ) const;
121 
122  std::vector<SplatResult> getSearchResults() const;
127  static const QString SPLATALOGUE_UNITS;
128  static const QString SEARCH_DEFAULT_UNITS;
129 
130  signals:
131  void searchCompleted();
132  void redshiftChanged();
133 
134  private slots:
135  void search();
136  void searchUnitsChanged( const QString& searchUnits );
137  void redshiftChanged( const QString& redshiftStr );
138  void dopplerShiftChanged();
140  void searchFinished();
141  void prevResults();
142  void nextResults();
143  void stopSearch();
144 
145  private:
146 
147  static QString initialReferenceStr;
148 
150  void convertRangeLineEdit( QLineEdit* lineEdit, Converter* converter );
151  void initializeSearchRange( QLineEdit* lineEdit, double& value, bool* valid );
152  std::vector<string> initializeChemicalNames();
153  std::vector<string> initializeChemicalFormulas();
154  QList<QString> getSearchChemicals();
155  std::vector<string> convertStringFormats( const QList<QString>& names );
156  double redShiftToVelocity( QString velocityUnits) const;
157  double velocityToRedshift( QString velocityUnits ) const;
158  void startSearchThread();
159  void setSearchRangeDefault();
160  double setRangeValue( double value, QString units );
161  double getRedShift() const;
162  casacore::MDoppler getRedShiftAdjustment( bool reverseRedshift) const;
163 
166  };
167 
168  Ui::SearchMoleculesWidget ui;
169 
170  QString unitStr;
172  std::vector<SplatResult> searchResults;
173  QList<QString> velocityUnitsList;
174  QMap<QString, casacore::MRadialVelocity::Types> radialVelocityTypeMap;
175  QMap<QString, casacore::MDoppler::Types> dopplerTypeMap;
181  QProgressDialog progressBar;
182 
183  //For conversion
185 
186  //Scrolling support
190  static const double SPEED_LIGHT;
191  static const QString M_PER_SEC;
192  static const QString KM_PER_SEC;
193 
194  static const double SPLATALOGUE_DEFAULT_MIN;
195  static const double SPLATALOGUE_DEFAULT_MAX;
197  };
198 
199 }
200 
201 #endif // SEARCHMOLECULESWIDGET_H
SearchMoleculesWidget(QWidget *parent=0)
QMap< QString, casacore::MDoppler::Types > dopplerTypeMap
void setAstronomicalFilters(Searcher *searcher)
void setRange(double min, double max, QString units)
double redShiftToVelocity(QString velocityUnits) const
std::vector< string > initializeChemicalFormulas()
#define max(a, b)
Definition: hio.h:44
virtual long doSearchCount(string &errorMsg)=0
virtual void stopSearch()=0
Provide a way to interrupt long searches.
#define min(a, b)
Definition: hio.h:45
std::vector< string > initializeChemicalNames()
static void setInitialReferenceFrame(QString initialReferenceStr)
A Measure: Doppler shift.
Definition: MDoppler.h:134
static const double SPLATALOGUE_DEFAULT_MIN
Interface needed to support molecular line searching and identification.
Definition: Searcher.h:35
Responsible for running the search algorithm in the background so that we don&#39;t freeze the GUI...
virtual std::vector< SplatResult > doSearch(string &errorMsg, int offset)=0
Doing the search.
static const double SPLATALOGUE_DEFAULT_MAX
double getRedShift() const
Interface provides decoupling between classes that initialize a search such as SearchMoleculesWidget ...
QMap< QString, casacore::MRadialVelocity::Types > radialVelocityTypeMap
int searchResultCount
Scrolling support.
casacore::String getErrorMessage() const
void setResultDisplay(SearchMoleculesResultDisplayer *resultDisplay)
std::vector< SplatResult > getResults() const
void setSpectralCoordinate(casacore::SpectralCoordinate coord)
std::vector< SplatResult > searchResults
double setRangeValue(double value, QString units)
QList< QString > getSearchChemicals()
std::vector< SplatResult > searchResults
Types
Types of known MRadialVelocity Warning: The order defines the order in the translation matrix FromTo...
casacore::String getErrorMessageCount() const
void setCanvas(QtCanvas *drawCanvas)
Types
Types of known MDopplers Warning: The order defines the order in the translation matrix FromTo in th...
Definition: MDoppler.h:149
double getRedShiftedValue(bool reverseRedshift, double value, bool *valid) const
static const QString SEARCH_DEFAULT_UNITS
SearchThread(Searcher *searcher, int offset)
QString getUnit() const
Interconvert pixel and frequency values.
casacore::MDoppler::Types getDopplerType() const
void initializeSearchRange(QLineEdit *lineEdit, double &value, bool *valid)
void searchUnitsChanged(const QString &searchUnits)
casacore::MFrequency::Types getReferenceFrequency() const
SearchMoleculesResultDisplayer * resultDisplay
casacore::MRadialVelocity::Types getReferenceFrame() const
String: the storage and methods of handling collections of characters.
Definition: String.h:223
casacore::SpectralCoordinate coord
For conversion.
Types
Types of known MFrequencies Warning: The order defines the order in the translation matrix FromTo in...
Definition: MFrequency.h:176
void setCountNeeded(bool needed)
std::vector< string > convertStringFormats(const QList< QString > &names)
void convertRangeLineEdit(QLineEdit *lineEdit, Converter *converter)
std::vector< SplatResult > getSearchResults() const
double velocityToRedshift(QString velocityUnits) const
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
casacore::MDoppler getRedShiftAdjustment(bool reverseRedshift) const