casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FeatherPlotWidget.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 #ifndef FEATHERPLOTWIDGET_QO_H
26 #define FEATHERPLOTWIDGET_QO_H
27 
28 #include <QWidget>
29 
30 #include <guitools/Feather/FeatherPlotWidget.ui.h>
35 #include <casaqt/QwtConfig.h>
36 #include <casa/Arrays/Vector.h>
37 #include <qwt_plot.h>
38 #include <qwt_legend.h>
39 
40 #if QWT_VERSION < 0x060000
41 #include <qwt_polygon.h>
42 #include <qwt_double_rect.h>
43 #endif
44 
45 using namespace std;
46 
47 class QwtPlotPicker;
48 class QwtPlotMarker;
49 
50 namespace casa {
51 
52 
53 class FeatherPlotWidget : public QWidget
54 {
55  Q_OBJECT
56 
57 public:
60 
61  FeatherPlotWidget(const QString& title, FeatherPlot::PlotType plotType, QWidget *parent = 0);
62 
63  //Setting the data into the plots
64  void setData( const casacore::Vector<float>& xValues, const casacore::Vector<float>& yValues, DataType dType );
65  virtual void addSumData();
66 
67  void clearPlot();
68  void clearData();
69  void clearLegend();
70 
71  //Preferences
72  void setPlotColors( const QMap<CurveType,CurveDisplay>& colorMap);
73  virtual void setScatterCurves( const QString& /*title*/, CurveType /*xScatter*/, const QList<CurveType>& /*yScatters*/ ){};
74  void setLineThickness( int thickness );
75  void setLegendVisibility( bool v );
76  void setDotSize( int size );
77  void setLogScale( bool uvScale, bool logScale );
78  void refresh();
79 
80  //Zooming
81  void changeZoom90( bool zoom );
82  void zoomRectangle( double minX, double maxX, double minY, double maxY);
83 
84  void zoomNeutral();
85  void resetZoomRectangleColor();
86  virtual void addZoomNeutralCurves() = 0;
87 
88  QWidget* getExternalAxisControl( QwtPlot::Axis position );
89 
90  void insertLegend( QWidget* parent );
92 
93  //Dish diameter marker
94  bool moveDiameterMarker( const QPoint& pos );
95  double getDishDiameter() const;
96  bool isDiameterSelectorMode() const;
97  void setDishDiameter( double value = -1, bool scale=true);
98  void resetDishDiameterLineColor();
99 
100  //Left mouse mode
101  void setRectangleZoomMode();
102  void setDiameterSelectorMode();
103 
104 signals:
105  void dishDiameterChanged( double newValue);
106  void rectangleZoomed( double minX, double maxX, double minY, double maxY );
107 
108 protected:
109  FeatherDataType::DataType getDataTypeForCurve( CurveType cType ) const;
110 
111  void resizeEvent( QResizeEvent* event );
112  void resetData( DataType dataType, const casacore::Vector<float>& xValues, const casacore::Vector<float>& yValues );
113  virtual void addSumData( bool logAmplitude);
114  pair<double,double> getMaxMin( QVector<double> values, FeatherCurveType::CurveType curveType ) const;
115  virtual void zoomRectangleOther( double minX, double maxX, double minY, double maxY )=0;
116  virtual void zoom90Other( double dishPosition) = 0;
117  void addPlotCurve( const QVector<double>& xValues, const QVector<double>& yValues,
118  DataType dType, bool sumCurve );
119  void addPlotCurve( const QVector<double>& xValues,
120  const QVector<double>& yValues, QwtPlot::Axis axis,
121  CurveType curveType, bool sumCurve );
122  pair<QVector<double>,QVector<double> > limitX( DataType dType, double xCutOff );
123  pair<QVector<double>,QVector<double> > limitX( DataType dType, double minValue, double maxValue );
124  void initializeDomainLimitedData( double minValue, double maxValue,
125  QVector<double>& xValues, QVector<double>& yValues,
126  const QVector<double>& originalXValues, const QVector<double>& originalYValues) const;
127  void initializeSumData( QVector<double>& sumX, QVector<double>& sumY, bool logScale );
128  void initializeMarkers();
129  virtual void resetColors();
131  QwtPlot::Axis sliceAxis;
132  QwtPlot::Axis weightAxis;
133  QwtPlot::Axis scatterAxis;
134  QMap<DataType, std::pair<QVector<double>,QVector<double> > > plotData;
135  QMap<CurveType,CurveDisplay> curvePreferences;
136 
137 private slots:
138  void zoomRectangleSelected( const QwtDoubleRect& rect );
139  void diameterSelected( const QwtDoublePoint& pos );
140 
141 private:
142 
143  void resetPlot( FeatherPlot::PlotType plotType );
144  void initializeZooming();
145  void initializeDiameterMarker();
146  void initializeDiameterSelector();
147  void setZoomRectangleState( double minX, double maxX, double minY, double maxY);
148 
149  void removeMarkers();
150  void changeLeftMouseMode();
151  QwtPlot::Axis getAxisYForData( DataType dType );
152  CurveType getCurveTypeForData( DataType dType );
153 
154  QString plotTitle;
155  double dishPosition;
156  const int MARKER_WIDTH;
157  QwtPlotPicker* zoomer;
158  QwtPlotMarker* diameterMarker;
159  QwtPlotPicker* diameterSelector;
160 
161 
162  enum LeftMouseMode { RECTANGLE_ZOOM, DIAMETER_SELECTION };
164  enum ZoomState { ZOOM_NEUTRAL, ZOOM_90, ZOOM_RECTANGLE };
166  double zoomMinX;
167  double zoomMaxX;
168  double zoomMinY;
169  double zoomMaxY;
170  Ui::FeatherPlotWidgetClass ui;
171 };
172 
173 }
174 #endif // FEATHERPLOTWIDGET_H
Ui::FeatherPlotWidgetClass ui
size_t size() const
FeatherDataType::DataType DataType
FeatherCurveType::CurveType CurveType
virtual void setScatterCurves(const QString &, CurveType, const QList< CurveType > &)
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
QMap< CurveType, CurveDisplay > curvePreferences
CurveType
Note: Order in this listing is important.
QMap< DataType, std::pair< QVector< double >, QVector< double > > > plotData