FeatherPlotWidget.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 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     //Setting the data into the plots
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     //Preferences
00072     void setPlotColors( const QMap<CurveType,CurveDisplay>& colorMap);
00073     virtual void setScatterCurves( const QString& /*title*/, CurveType /*xScatter*/, const QList<CurveType>& /*yScatters*/ ){};
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     //Zooming
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     //Dish diameter marker
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         //Left mouse mode
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
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1