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 FEATHERPLOTWIDGET_QO_H
00026 #define FEATHERPLOTWIDGET_QO_H
00027
00028 #include <QtGui/QWidget>
00029
00030 #include <guitools/Feather/FeatherPlotWidget.ui.h>
00031 #include <guitools/Feather/FeatherPlot.h>
00032 #include <guitools/Feather/FeatherDataType.h>
00033 #include <guitools/Feather/FeatherCurveType.h>
00034 #include <guitools/Feather/CurveDisplay.h>
00035 #include <casaqt/QwtConfig.h>
00036 #include <casa/Arrays/Vector.h>
00037 #include <qwt_plot.h>
00038 #include <qwt_legend.h>
00039
00040 #if QWT_VERSION < 0x060000
00041 #include <qwt_polygon.h>
00042 #include <qwt_double_rect.h>
00043 #endif
00044
00045 using namespace std;
00046
00047 class QwtPlotPicker;
00048 class QwtPlotMarker;
00049
00050 namespace casa {
00051
00052
00053 class FeatherPlotWidget : public QWidget
00054 {
00055 Q_OBJECT
00056
00057 public:
00058 typedef FeatherDataType::DataType DataType;
00059 typedef FeatherCurveType::CurveType CurveType;
00060
00061 FeatherPlotWidget(const QString& title, FeatherPlot::PlotType plotType, QWidget *parent = 0);
00062
00063
00064 void setData( const Vector<Float>& xValues, const Vector<Float>& yValues, DataType dType );
00065 virtual void addSumData();
00066
00067 void clearPlot();
00068 void clearData();
00069 void clearLegend();
00070
00071
00072 void setPlotColors( const QMap<CurveType,CurveDisplay>& colorMap);
00073 virtual void setScatterCurves( const QString& , CurveType , const QList<CurveType>& ){};
00074 void setLineThickness( int thickness );
00075 void setLegendVisibility( bool v );
00076 void setDotSize( int size );
00077 void setLogScale( bool uvScale, bool logScale );
00078 void refresh();
00079
00080
00081 void changeZoom90( bool zoom );
00082 void zoomRectangle( double minX, double maxX, double minY, double maxY);
00083
00084 void zoomNeutral();
00085 void resetZoomRectangleColor();
00086 virtual void addZoomNeutralCurves() = 0;
00087
00088 QWidget* getExternalAxisControl( QwtPlot::Axis position );
00089
00090 void insertLegend( QWidget* parent );
00091 ~FeatherPlotWidget();
00092
00093
00094 bool moveDiameterMarker( const QPoint& pos );
00095 double getDishDiameter() const;
00096 bool isDiameterSelectorMode() const;
00097 void setDishDiameter( double value = -1, bool scale=true);
00098 void resetDishDiameterLineColor();
00099
00100
00101 void setRectangleZoomMode();
00102 void setDiameterSelectorMode();
00103
00104 signals:
00105 void dishDiameterChanged( double newValue);
00106 void rectangleZoomed( double minX, double maxX, double minY, double maxY );
00107
00108 protected:
00109 FeatherDataType::DataType getDataTypeForCurve( CurveType cType ) const;
00110
00111 void resizeEvent( QResizeEvent* event );
00112 void resetData( DataType dataType, const Vector<Float>& xValues, const Vector<Float>& yValues );
00113 virtual void addSumData( bool logAmplitude);
00114 pair<double,double> getMaxMin( QVector<double> values, FeatherCurveType::CurveType curveType ) const;
00115 virtual void zoomRectangleOther( double minX, double maxX, double minY, double maxY )=0;
00116 virtual void zoom90Other( double dishPosition) = 0;
00117 void addPlotCurve( const QVector<double>& xValues, const QVector<double>& yValues,
00118 DataType dType, bool sumCurve );
00119 void addPlotCurve( const QVector<double>& xValues,
00120 const QVector<double>& yValues, QwtPlot::Axis axis,
00121 CurveType curveType, bool sumCurve );
00122 pair<QVector<double>,QVector<double> > limitX( DataType dType, double xCutOff );
00123 pair<QVector<double>,QVector<double> > limitX( DataType dType, double minValue, double maxValue );
00124 void initializeDomainLimitedData( double minValue, double maxValue,
00125 QVector<double>& xValues, QVector<double>& yValues,
00126 const QVector<double>& originalXValues, const QVector<double>& originalYValues) const;
00127 void initializeSumData( QVector<double>& sumX, QVector<double>& sumY, bool logScale );
00128 void initializeMarkers();
00129 virtual void resetColors();
00130 FeatherPlot* plot;
00131 QwtPlot::Axis sliceAxis;
00132 QwtPlot::Axis weightAxis;
00133 QwtPlot::Axis scatterAxis;
00134 QMap<DataType, std::pair<QVector<double>,QVector<double> > > plotData;
00135 QMap<CurveType,CurveDisplay> curvePreferences;
00136
00137 private slots:
00138 void zoomRectangleSelected( const QwtDoubleRect& rect );
00139 void diameterSelected( const QwtDoublePoint& pos );
00140
00141 private:
00142
00143 void resetPlot( FeatherPlot::PlotType plotType );
00144 void initializeZooming();
00145 void initializeDiameterMarker();
00146 void initializeDiameterSelector();
00147 void setZoomRectangleState( double minX, double maxX, double minY, double maxY);
00148
00149 void removeMarkers();
00150 void changeLeftMouseMode();
00151 QwtPlot::Axis getAxisYForData( DataType dType );
00152 CurveType getCurveTypeForData( DataType dType );
00153
00154 QString plotTitle;
00155 double dishPosition;
00156 const int MARKER_WIDTH;
00157 QwtPlotPicker* zoomer;
00158 QwtPlotMarker* diameterMarker;
00159 QwtPlotPicker* diameterSelector;
00160
00161
00162 enum LeftMouseMode { RECTANGLE_ZOOM, DIAMETER_SELECTION };
00163 LeftMouseMode leftMouseMode;
00164 enum ZoomState { ZOOM_NEUTRAL, ZOOM_90, ZOOM_RECTANGLE };
00165 ZoomState zoomState;
00166 double zoomMinX;
00167 double zoomMaxX;
00168 double zoomMinY;
00169 double zoomMaxY;
00170 Ui::FeatherPlotWidgetClass ui;
00171 };
00172
00173 }
00174 #endif // FEATHERPLOTWIDGET_H