casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SlicePlot.qo.h
Go to the documentation of this file.
00001 //# Copyright (C) 1994,1995,1996,1997,1998,1999,2000
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 
00026 #ifndef SLICEPLOT_H_
00027 #define SLICEPLOT_H_
00028 
00029 #include <qwt_plot.h>
00030 #include <QMap>
00031 #include <casa/Arrays/Vector.h>
00032 #include <display/region/RegionEnums.h>
00033 #include <display/Slicer/ImageSlice.qo.h>
00034 
00035 class QwtPlotCurve;
00036 
00037 
00038 namespace casa {
00039 
00040 template <class T> class ImageInterface;
00041 class ImageAnalysis;
00042 
00043 class SlicePlot : public QwtPlot {
00044 
00045 Q_OBJECT
00046 
00047 public:
00048         SlicePlot(QWidget *parent = NULL, bool fullVersion = false );
00049 
00050         //Data
00051         void setImage( ImageInterface<float>* img );
00052         void updateChannel( int channel );
00053         void setRegionSelected( int regionId, bool selected );
00054 
00055         //Look and feel
00056         void resetCurveColors( bool viewerColors, bool polylineColorUnit,
00057                         QList<QColor> accumulateCurveColors);
00058         void setViewerCurveColor( int regionId, const QString& colorName );
00059         void setUseViewerColors( bool viewerColors );
00060         void setPlotPreferences( int lineWidth, int markerSize );
00061 
00062         //Setting slice parameters.
00063         void setSampleCount( int sampleCount );
00064         void setInterpolationMethod( const String& method );
00065         void setAccumulateSlices( bool accumulate );
00066 
00067         //Wipe out only the curves that shouldn't be displayed under
00068         //the current settings.
00069         void clearCurves();
00070         //Wipe out all curves.
00071         void clearCurvesAll();
00072         bool toAscii( const QString& fileName );
00073 
00074         //Statistics
00075         void addStatistic( int regionId );
00076         void removeStatistics( );
00077         void removeStatistic( int regionId);
00078         void setStatisticsLayout( QLayout* layout );
00079         void updatePositionInformation( int id, const QVector<String>& info );
00080         void markPositionChanged(int regionId,int segmentIndex,float percentage);
00081         void markVisibilityChanged(int regionId,bool showMarker);
00082         bool isFullVersion() const;
00083 
00084         virtual ~SlicePlot();
00085 
00086         const static QString DISTANCE_AXIS;
00087         const static QString POSITION_X_AXIS;
00088         const static QString POSITION_Y_AXIS;
00089         const static QString UNIT_X_PIXEL;
00090         const static QString UNIT_X_ARCSEC;
00091         const static QString UNIT_X_ARCMIN;
00092         const static QString UNIT_X_ARCDEG;
00093 
00094 signals:
00095         void markerPositionChanged(int regionId,int segmentIndex,float percentage);
00096         void markerVisibilityChanged(int regionId,bool showMarker);
00097 
00098 public slots:
00099         void updatePolyLine(  int regionId,viewer::region::RegionChanges regionChanges,
00100                                 const QList<double> & linearX, const QList<double> & linearY,
00101                                 const QList<int> &pixelX, const QList<int> & pixelY);
00102         void setXAxis( const QString& newAxis );
00103         void xAxisUnitsChanged( const QString& units );
00104         void segmentMarkerVisibilityChanged( bool visible );
00105 
00106 private:
00107         SlicePlot( const SlicePlot& other );
00108         SlicePlot operator=(const SlicePlot& other );
00109         ImageSlice* getSlicerFor( int regionId );
00110         SliceStatisticsFactory::AxisXUnits getUnitMode() const;
00111         SliceStatisticsFactory::AxisXChoice getXAxis() const;
00112         void initPlot();
00113         void resetCurves();
00114         void addPlotCurve( int regionId );
00115         void initAxisFont( int axisId, const QString& axisTitle );
00116         void sliceFinished( int regionId);
00117         QString getAxisLabel() const;
00118         void updateSelectedRegionId( int selectedRegionId );
00119         void updatePolyLine(  int regionId, const QList<double>& worldX,
00120                         const QList<double>& worldY, const QList<int>& pixelX,
00121                         const QList<int>& pixelY);
00122         void deletePolyLine( int regionId );
00123 
00124         int getColorIndex( int regionId ) const;
00125         int assignCurveColors( int initialColorIndex, int regionId );
00126         void resetExistingCurveColors();
00127 
00128         QList<QColor> curveColors;
00129         ImageInterface<float>* image;
00130         ImageAnalysis* imageAnalysis;
00131         QMap<int, ImageSlice*> sliceMap;
00132 
00133         Vector<Int> coords;
00134         int curveWidth;
00135         int markerSize;
00136         bool accumulateSlices;
00137         bool fullVersion;
00138         bool viewerColors;
00139         bool polylineColorUnit;
00140         bool segmentMarkers;
00141         int sampleCount;
00142         int currentRegionId;
00143         const int AXIS_FONT_SIZE;
00144         String interpolationMethod;
00145         QString xAxis;
00146         QString xAxisUnits;
00147         Vector<Int> axes;
00148         QLayout* statLayout;
00149         SliceStatisticsFactory* factory;
00150 };
00151 
00152 } /* namespace casa */
00153 #endif /* SLICEPLOT_H_ */