00001 #ifndef SPECTRALPOSITIONINGWIDGET_QO_H 00002 #define SPECTRALPOSITIONINGWIDGET_QO_H 00003 00004 #include <QtGui/QWidget> 00005 #include <display/QtPlotter/SpectralPositioningWidget.ui.h> 00006 #include <casa/Arrays/Vector.h> 00007 namespace casa { 00008 00009 class ProfileTaskMonitor; 00010 class LogIO; 00011 00012 class SpectralPositioningWidget : public QWidget { 00013 Q_OBJECT 00014 00015 public: 00016 SpectralPositioningWidget(QWidget *parent = 0); 00017 void setTaskMonitor( ProfileTaskMonitor* monitor ); 00018 void setLogger( LogIO* logger ); 00019 00020 void updateRegion( const Vector<Double> px, const Vector<Double> py, 00021 const Vector<Double> wx, const Vector<Double> wy ); 00022 ~SpectralPositioningWidget(); 00023 00024 private slots: 00025 void boxSpecChanged( int index ); 00026 void locationSelectionTypeChanged( int index ); 00027 void locationUnitsChanged( int index ); 00028 void setPosition(); 00029 00030 private: 00031 void updateUI(); 00032 void updateUIWorldBox(); 00033 void updateUIWorldPoint(); 00034 void updateUIPixelBox(); 00035 void updateUIPixelPoint(); 00039 void initSpectrumPosition(); 00040 void pageUpdate( int selectionIndex, int unitIndex ); 00041 00042 bool populateWorlds( const QList<int> &pixelX, const QList<int> &pixelY, 00043 QList<double> &worldX, QList<double> &worldY ); 00044 bool fillPointWorld( QList<double> &worldX, QList<double> &worldY ); 00045 void fillPointPixel( QList<int> &pixelX, QList<int>&pixelY )const; 00046 bool fillBoxPixel( QList<int> &pixelX, QList<int>&pixelY ); 00047 bool fillBoxWorld( QList<double> &worldX, QList<double> & worldY ); 00048 bool fillBasedOnBoxSpecification( const double* const firstXPix, const double * const firstYPix, 00049 const double* const secondXPix, const double* const secondYPix, 00050 double* const blcxPix, double* const blcyPix, 00051 double* const trcxPix, double* const trcYPix, bool pixels=true ); 00052 double toRadians( Bool& valid, QLineEdit * lineEdit ); 00053 void switchBoxLabels( int index, int pageIndex, QLabel* const x1Label, QLabel* const y1Label, 00054 QLabel* const x2Label, QLabel* const y2Label ); 00055 void setPixelLineEdits( double topLeft, double bottomLeft, 00056 double topRight, double bottomRight ); 00057 void setWorldEdits( double topLeft, double bottomLeft, 00058 double topRight, double bottomRight ); 00059 void adjustPoint( const Vector<Double>& newX, const Vector<Double>& newY, 00060 Vector<Double>& xValues, Vector<Double>& yValues ); 00061 Ui::SpectralPositioningWidgetClass ui; 00062 00063 enum PositionTypeIndex { POINT, BOX, END_POSITION_TYPE }; 00064 enum UnitIndex {RADIAN, PIXEL, END_UNIT }; 00065 QIntValidator* pixelValidator; 00066 enum StackPages { POINT_PIXEL, POINT_RA_DEC, BOX_PIXEL, BOX_RA_DEC }; 00067 enum BoxSpecificationIndex { TL_LENGTH_HEIGHT, CENTER_LENGTH_HEIGHT, TL_BR, BL_TR, 00068 TL_LENGTH_HEIGHT_WORLD, CENTER_LENGTH_HEIGHT_WORLD, TL_BR_WORLD, BL_TR_WORLD, END_SPEC 00069 }; 00070 QMap<BoxSpecificationIndex,QList<QString> > boxLabelMap; 00071 ProfileTaskMonitor* profileTaskMonitor; 00072 LogIO* logger; 00073 Vector<Double> pixelXValues; 00074 Vector<Double> pixelYValues; 00075 Vector<Double> worldXValues; 00076 Vector<Double> worldYValues; 00077 }; 00078 } 00079 #endif // SPECTRALPOSITIONINGWIDGET_H