casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
QPScatterPlot.h
Go to the documentation of this file.
00001 //# QPScatterPlot.h: Qwt implementation of generic ScatterPlot class.
00002 //# Copyright (C) 2008
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: $
00027 #ifndef QPSCATTERPLOT_H_
00028 #define QPSCATTERPLOT_H_
00029 
00030 #ifdef AIPS_HAS_QWT
00031 
00032 #include <graphics/GenericPlotter/Plot.h>
00033 #include <casaqt/QwtPlotter/QPOptions.h>
00034 #include <casaqt/QwtPlotter/QPPlotItem.qo.h>
00035 
00036 #include <qwt_plot_item.h>
00037 #include <qwt_legend_item.h>
00038 
00039 #include <QObject>
00040 
00041 #include <casa/namespace.h>
00042 
00043 namespace casa {
00044 
00045 // Implementation of MaskedPlot, ErrorPlot, and ColoredPlot for Qwt plotter.
00046 class QPScatterPlot : public QPPlotItem, public MaskedScatterPlot,
00047                       public ErrorPlot, public ColoredPlot {
00048 public:
00049     // Static //
00050     
00051     // Convenient access to class name (QPScatterPlot).
00052     const static String CLASS_NAME;
00053     
00054     
00055     // Non-Static //
00056     
00057     // Constructor which takes the data (and determines its type) and an
00058     // optional title.
00059     QPScatterPlot(PlotPointDataPtr data, const String& title = "Scatter Plot");
00060     
00061     // Copy constructor for generic ScatterPlot.
00062     QPScatterPlot(const ScatterPlot& copy);
00063     
00064     // Destructor.
00065     ~QPScatterPlot();
00066     
00067     
00068     // Include overloaded methods.
00069     using Plot::setLine;
00070     using ScatterPlot::setSymbol;
00071     using MaskedScatterPlot::setMaskedLine;
00072     using MaskedScatterPlot::setMaskedSymbol;
00073     using ErrorPlot::setErrorLine;
00074     
00075     
00076     // PlotItem Methods //
00077     
00078     // Implements PlotItem::isValid().
00079     bool isValid() const;
00080     
00081     
00082     // QPPlotItem Methods //
00083     
00084     // Overrides QPPlotItem::shouldDraw().
00085     bool shouldDraw() const;
00086     
00087     // Overrides QwtPlotItem::boundingRect();
00088     QwtDoubleRect boundingRect() const;
00089     
00090     // Overrides QwtPlotItem::legendItem().
00091     QWidget* legendItem() const;
00092     
00093     
00094     // Plot Methods //
00095     
00096     // Implements Plot::dataChanged().
00097     void dataChanged() { itemChanged(); }
00098     
00099     // Implements Plot::linesShown().
00100     bool linesShown() const;
00101     
00102     // Implements Plot::setLinesShown().
00103     void setLinesShown(bool linesShown = true);
00104     
00105     // Implements Plot::line().
00106     PlotLinePtr line() const;
00107     
00108     // Implements Plot::setLine().
00109     void setLine(const PlotLine& line);
00110     
00111     
00112     // ScatterPlot Methods //
00113     
00114     // Implements ScatterPlot::pointData().
00115     PlotPointDataPtr pointData() const;
00116     
00117     // Implements ScatterPlot::symbolsShown().
00118     bool symbolsShown() const;
00119     
00120     // Implements ScatterPlot::setSymbolsShown().
00121     void setSymbolsShown(bool symbolsShown = true);
00122     
00123     // Implements ScatterPlot::symbol().
00124     PlotSymbolPtr symbol() const;
00125     
00126     // Implements ScatterPlot::setSymbol().
00127     void setSymbol(const PlotSymbol& symbol);
00128     
00129     
00130     // MaskedScatterPlot Methods //
00131     
00132     // Implements MaskedScatterPlot::maskedData().
00133     PlotMaskedPointDataPtr maskedData() const;
00134 
00135     // Implements MaskedScatterPlot::maskedLinesShown().
00136     bool maskedLinesShown() const;
00137 
00138     // Implements MaskedScatterPlot::setMaskedLinesShown().
00139     void setMaskedLinesShown(bool linesShown = true);
00140 
00141     // Implements MaskedScatterPlot::maskedLine().
00142     PlotLinePtr maskedLine() const;
00143 
00144     // Implements MaskedScatterPlot::setMaskedLine().
00145     void setMaskedLine(const PlotLine& line);
00146 
00147     // Implements MaskedScatterPlot::maskedSymbolsShown().
00148     bool maskedSymbolsShown() const;
00149 
00150     // Implements MaskedScatterPlot::setMaskedSymbolsShown().
00151     void setMaskedSymbolsShown(bool symbolsShown = true);
00152 
00153     // Implements MaskedScatterPlot::maskedSymbol().
00154     PlotSymbolPtr maskedSymbol() const;
00155 
00156     // Implements MaskedScatterPlot::setMaskedSymbol().
00157     void setMaskedSymbol(const PlotSymbol& symbol);
00158     
00159     
00160     // ErrorPlot Methods //
00161     
00162     // Implements ErrorPlot::errorData().
00163     PlotErrorDataPtr errorData() const;
00164     
00165     // Implements ErrorPlot::errorLineShown().
00166     bool errorLineShown() const;
00167     
00168     // Implements ErrorPlot::setErrorLineShown().
00169     void setErrorLineShown(bool show = true);
00170     
00171     // Implements ErrorPlot::errorLine().
00172     PlotLinePtr errorLine() const;
00173     
00174     // Implements ErrorPlot::setErrorLine().
00175     void setErrorLine(const PlotLine& line);
00176     
00177     // Implements ErrorPlot::errorCapSize().
00178     unsigned int errorCapSize() const;
00179     
00180     // Implements ErrorPlot::setErrorCapSize().
00181     void setErrorCapSize(unsigned int capSize);
00182     
00183     
00184     // ColoredPlot Methods //
00185     
00186     // Implements ColoredPlot::binnedColorData().
00187     PlotBinnedDataPtr binnedColorData() const;
00188     
00189     // Implements ColoredPlot::colorForBin().
00190     PlotColorPtr colorForBin(unsigned int bin) const;
00191     
00192     // Implements ColoredPlot::setColorForBin().
00193     void setColorForBin(unsigned int bin, const PlotColorPtr color);
00194     
00195 protected:
00196     // Implements QPPlotItem::className().
00197     const String& className() const { return CLASS_NAME; }
00198     
00199     // Implements QPLayerItem::draw_().
00200     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00201               const QwtScaleMap& yMap, const QRect& canvasRect,
00202               unsigned int drawIndex, unsigned int drawCount) const;
00203     
00204 private:
00205     // Data pointers.
00206     // <group>
00207     PlotPointDataPtr m_data;
00208     PlotMaskedPointDataPtr m_maskedData;
00209     PlotErrorDataPtr m_errorData;
00210     PlotBinnedDataPtr m_coloredData;
00211     // </group>
00212     
00213     // Customization objects.
00214     // <group>
00215     QPSymbol m_symbol;
00216     QPLine m_line;
00217     QPSymbol m_maskedSymbol;
00218     QPLine m_maskedLine;
00219     QPLine m_errorLine;
00220     unsigned int m_errorCap;
00221     // </group>
00222     
00223     // Binned colors.
00224     // <group>
00225     QList<QPColor*> m_colors;
00226     QList<QBrush> m_coloredBrushes;
00227     // </group>
00228     
00229     
00230     // Updates the binned color brushes.
00231     void updateBrushes();
00232 };
00233 
00234 }
00235 
00236 #endif
00237 
00238 #endif /*QPSCATTERPLOT_H_*/