BinPlotWidget.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 BINPLOTWIDGET_QO_H
00026 #define BINPLOTWIDGET_QO_H
00027 
00028 #include <QtGui/QWidget>
00029 
00030 #include <guitools/Histogram/BinPlotWidget.ui.h>
00031 #include <guitools/Histogram/HeightSource.h>
00032 #include <guitools/Histogram/FootPrintWidget.qo.h>
00033 #include <images/Regions/ImageRegion.h>
00034 #include <casa/aips.h>
00035 #include <casa/aipstype.h>
00036 #include <qwt_plot.h>
00037 #include <qwt_plot_picker.h>
00038 #include <vector>
00039 #include <QDebug>
00040 #include <QMenu>
00041 
00042 using namespace std;
00043 
00044 class QwtPlotMarker;
00045 class QwtPlotCurve;
00046 class QwtLinearColorMap;
00047 class QWidgetAction;
00048 
00049 namespace casa {
00050 
00051 template <class T> class ImageInterface;
00052 template <class T> class Vector;
00053 class FitWidget;
00054 class RangePicker;
00055 class ToolTipPicker;
00056 class Histogram;
00057 class HistogramMarkerGaussian;
00058 class HistogramMarkerPoisson;
00059 class RangeControlsWidget;
00060 class BinCountWidget;
00061 class ChannelRangeWidget;
00062 class ZoomWidget;
00063 
00064 
00077 class BinPlotWidget : public QWidget, public HeightSource{
00078     Q_OBJECT
00079 
00080 friend class RangePicker;
00081 
00082 public:
00089     BinPlotWidget( bool fitControls, bool rangeControls, bool plotModeControls,
00090         QWidget* parent);
00091 
00092     bool setImage( const SHARED_PTR<const ImageInterface<Float> > img, bool waitOnHistogram = false );
00093     bool setImageRegion( ImageRegion* imageRegion, int id );
00094     void deleteImageRegion( int id );
00095     void imageRegionSelected( int id );
00096     virtual void postMessage( const QString& msg );
00097 
00098     std::vector<float> getXValues() const;
00099     pair<double,double> getMinMaxValues() const;
00100     void setMinMaxValues( double minValue, double maxValue, bool updateGraph=true );
00101 
00102     //Customizing the display
00103     void hideMaximumRange();
00104     void setColorLookups( const Vector<uInt> & lookups );
00105     void setColorMap( QwtLinearColorMap* colorMap );
00106     void setColorScaleMax( int max );
00107     void setMultiColored( bool multipleColors );
00108     void setLineMode( bool lineMode );
00109     void setDisplayPlotTitle( bool display );
00110     void setDisplayAxisTitles( bool display );
00111     void setHistogramColor( QColor color );
00112     void setFitEstimateColor( QColor color );
00113     void setFitCurveColor( QColor color );
00114     void setMultipleHistogramColors( const QList<QColor>& colors );
00115     void setAxisLabelFont( int size );
00116     void setChannelCount( int count );
00117     void setChannelValue( int value );
00118     void addZoomActions( bool rangeControl, QMenu* zoomMenu );
00119     void addDisplayActions( QMenu* menu, QWidgetAction* binCountAction );
00120     void addPlotModeActions( QMenu* menu, QWidgetAction* channelRangeAction=NULL,
00121                 QWidgetAction* footPrintAction = NULL );
00122     void setPlotMode( int mode );
00123     bool isEmpty() const;
00124     ~BinPlotWidget();
00125 
00126 signals:
00127         void postStatusMessage( const QString& msg );
00128         void rangeChanged();
00129 
00130 
00131 public slots:
00132         void fitModeChanged();
00133         void plotModeChanged( int mode );
00134         void setDisplayStep( bool display );
00135         void setDisplayLogY( bool display );
00136         void clearFit();
00137         void clearAll();
00138 
00139         //Saving the Histogram
00140         void toAscii( const QString& filePath );
00141         void toPing( const QString& filtPath, int width, int height );
00142 
00143         //The channel has changed value.
00144         void channelRangeChanged( int minValue, int maxValue, bool allChannels, bool automatic, int specIndex=-1 );
00145 
00146         //Histogramming an image versus a region.
00147         void imageModeSelected( bool enabled );
00148         void regionModeSelected( bool enabled );
00149 
00150 protected:
00151     virtual void resizeEvent( QResizeEvent* event );
00152     virtual void keyPressEvent( QKeyEvent* event );
00153     /*Overriden because we weren't getting the first "Shift" to bring
00154      * up the context menu when the mouse first entered the histogram.
00155      * We set the focus on this widget when the mouse enters so it will
00156      * get that first "Shift" without having to do a click first.
00157      */
00158     virtual void enterEvent( QEvent* event );
00159         virtual void mousePressEvent( QMouseEvent* event );
00160 
00161 
00162 private slots:
00163         void lineMoved( const QPoint& pt );
00164         void lineSelected();
00165         void clearRange();
00166         void defineCurve( int id, const QColor& curveColor, bool clear=true);
00167         void minMaxChanged();
00168         void showContextMenu( const QPoint& pt );
00169         void centerPeakSpecified();
00170         void lambdaSpecified();
00171         void fwhmSpecified();
00172         void fitDone( const QString& msg );
00173         void zoomContextFinished();
00174         void zoomMenuFinished();
00175         void resetGaussianFitMarker();
00176         void resetPoissonFitMarker();
00177 
00178         void zoomNeutral();
00179         //Zoom based on an intensity range specified by the user using the range controls widget
00180         void zoomRange();
00181         //Zoom based on an intensity range specified by the user using the zoom context menu.
00182         void zoomPercentage( float minValue, float maxValue);
00183         void binCountChanged( int count );
00184 
00185         void regionAllModeSelected( bool enabled );
00186 
00187 private:
00188         BinPlotWidget( const BinPlotWidget& );
00189         BinPlotWidget& operator=( const BinPlotWidget& );
00190         void initializeFitWidget( bool fitControls );
00191         void initializeDisplayActions();
00192         void initializeZoomControls( bool rangeControls );
00193         void initializePlotModeControls( bool enable );
00194         void initializeGaussianFitMarker();
00195         void initializePoissonFitMarker();
00196         void initializeRangeControls( bool rangeControls);
00197         void connectZoomActions( ZoomWidget* zoomWidget );
00198         void clearGaussianFitMarker();
00199         void clearPoissonFitMarker();
00200         void clearHistograms();
00201         void clearCurves();
00202         void makeHistogram( int id, const QColor& histogramColor, bool clearCurve=true);
00203         void rectangleSizeChanged();
00204         void resetAxisTitles();
00205         void resetPlotTitle();
00206         void reset();
00207         bool resetImage( bool waitOnHistogram = false );
00208         void resetRegion();
00209         void resetRectangleMarker();
00210         void defineCurveLine( int id, const QColor& lineColor );
00211         void defineCurveHistogram( int id, const QColor& histogramColor );
00212         QwtPlotCurve* addCurve( QVector<double>& xValues, QVector<double>& yValues, const QColor& curveColor );
00213         bool isPrintOut( int id ) const;
00214         bool isPrincipalHistogram( int id ) const;
00215         bool isPlotContains( int x, int y );
00216         virtual int getCanvasHeight();
00217         Histogram* findHistogramFor( int id );
00218         int getSelectedId() const;
00219         QColor getPieceColor( int index, const QColor& defaultColor ) const;
00220 
00221         void zoom( float percent );
00222         void zoomRangeMarker( double startValue, double endValue );
00223     Ui::BinPlotWidgetClass ui;
00224 
00225     enum ContextMenuMode{ ZOOM_CONTEXT,DISPLAY_CONTEXT,FIT_CONTEXT };
00226     ContextMenuMode contextMenuMode;
00227 
00228     bool displayPlotTitle;
00229     bool displayAxisTitles;
00230     bool multiColored;
00231     bool allChannels;
00232     int spectralIndex;
00233     int minChannel;
00234     int maxChannel;
00235 
00236     QColor curveColor;
00237     QColor selectionColor;
00238     QColor fitEstimateColor;
00239     QColor fitCurveColor;
00240     QList<QColor> multipleHistogramColors;
00241     QwtLinearColorMap* colorMap;
00242     Vector<uInt> colorLookups;
00243     int colorScaleMax;
00244 
00245     //Histogram & data
00246     QList<QwtPlotCurve*> curves;
00247     QMap<int,Histogram*> histogramMap;
00248     SHARED_PTR<const ImageInterface<Float> > image;
00249     QwtPlot binPlot;
00250     const QString NO_DATA;
00251     const QString NO_DATA_MESSAGE;
00252     const int IMAGE_ID;
00253     int selectedId;
00254 
00255     //Specifying a range with the histogram
00256     QwtPlotPicker* dragLine;
00257     RangePicker* rectMarker;
00258     ToolTipPicker* toolTipPicker;
00259     RangeControlsWidget* rangeControlWidget;
00260     QMenu contextMenuZoom;
00261 
00262     QWidgetAction* zoomActionContext;
00263     ZoomWidget* zoomWidgetContext;
00264     QWidgetAction* zoomActionMenu;
00265     ZoomWidget* zoomWidgetMenu;
00266     double rectX;
00267     double rectWidth;
00268 
00269     //Fitting the histogram
00270     QAction lambdaAction;
00271     QAction centerPeakAction;
00272     QAction fwhmAction;
00273     QMenu contextMenu;
00274     FitWidget* fitWidget;
00275     QwtPlotCurve* fitCurve;
00276     QPoint fitPosition;
00277     HistogramMarkerGaussian* fitEstimateMarkerGaussian;
00278     HistogramMarkerPoisson* fitEstimateMarkerPoisson;
00279 
00280     //Plot Display
00281     const QString LOG_COUNT;
00282     QAction stepFunctionNoneAction;
00283     QAction stepFunctionAction;
00284     QAction stepFunctionFilledAction;
00285     QAction logActionY;
00286     QAction clearAction;
00287     enum HistogramOptions{HISTOGRAM_FILLED,HISTOGRAM_OUTLINE,HISTOGRAM_LINE};
00288     bool displayLogY;
00289     QMenu contextMenuDisplay;
00290 
00291     //Plot Control
00292     //We should be able to use just one binCountAction and binCountWidget
00293     //However, to appear, the constructor has to take the appropriate
00294     //menu as a parent.
00295     QWidgetAction* binCountActionContext;
00296     QWidgetAction* channelRangeActionContext;
00297     QWidgetAction* footPrintActionContext;
00298 
00299     QWidgetAction* binCountActionMenu;
00300     QWidgetAction* channelRangeActionMenu;
00301     QWidgetAction* footPrintActionMenu;
00302 
00303     BinCountWidget* binCountWidgetContext;
00304     ChannelRangeWidget* channelRangeWidgetContext;
00305     FootPrintWidget* footPrintWidgetContext;
00306 
00307     BinCountWidget* binCountWidgetMenu;
00308     ChannelRangeWidget* channelRangeWidgetMenu;
00309     FootPrintWidget* footPrintWidgetMenu;
00310     QMenu contextMenuConfigure;
00311     FootPrintWidget::PlotMode plotMode;
00312 };
00313 
00314 }
00315 
00316 #endif // THRESHOLDINGBINPLOTWIDGET_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1