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 <QObject>
00037 
00038 namespace casa {
00039 
00040 // Implementation of MaskedPlot, ErrorPlot, and ColoredPlot for Qwt plotter.
00041 class QPScatterPlot : public QPPlotItem, public MaskedScatterPlot,
00042                       public ErrorPlot, public ColoredPlot {
00043 public:
00044     // Static //
00045     
00046     // Convenient access to class name (QPScatterPlot).
00047     const static String CLASS_NAME;
00048         
00049     // Non-Static //
00050     
00051     // Constructor which takes the data (and determines its type) and an
00052     // optional title.
00053     QPScatterPlot(PlotPointDataPtr data, const String& title = "Scatter Plot");
00054     
00055     // Copy constructor for generic ScatterPlot.
00056     QPScatterPlot(const ScatterPlot& copy);
00057     
00058     // Destructor.
00059     ~QPScatterPlot();
00060     
00061     
00062     // Include overloaded methods.
00063     using Plot::setLine;
00064     using ScatterPlot::setSymbol;
00065     using MaskedScatterPlot::setMaskedLine;
00066     using MaskedScatterPlot::setMaskedSymbol;
00067     using ErrorPlot::setErrorLine;
00068     
00069     
00070     // PlotItem Methods //
00071     
00072     // Implements PlotItem::isValid().
00073     bool isValid() const;
00074     
00075     
00076     // QPPlotItem Methods //
00077     
00078     // Overrides QPPlotItem::shouldDraw().
00079     bool shouldDraw() const;
00080     
00081     // Overrides QwtPlotItem::boundingRect();
00082     QwtDoubleRect boundingRect() const;
00083 
00084 #if QWT_VERSION >= 0x060000
00085     // implements QwtPlotItem::legendIcon
00086     QwtGraphic legendIcon(int index, const QSizeF& size) const;
00087 #else 
00088     // Overrides QwtPlotItem::legendItem().
00089     QWidget* legendItem() const;
00090 #endif
00091     
00092     
00093     // Plot Methods //
00094     
00095     // Implements Plot::dataChanged().
00096     void dataChanged() { itemChanged(); }
00097     
00098     // Implements Plot::linesShown().
00099     bool linesShown() const;
00100     
00101     // Implements Plot::setLinesShown().
00102     void setLinesShown(bool linesShown = true);
00103     
00104     // Implements Plot::line().
00105     PlotLinePtr line() const;
00106     
00107     // Implements Plot::setLine().
00108     void setLine(const PlotLine& line);
00109     
00110     
00111     // ScatterPlot Methods //
00112     
00113     // Implements ScatterPlot::pointData().
00114     PlotPointDataPtr pointData() const;
00115     
00116     // Implements ScatterPlot::symbolsShown().
00117     bool symbolsShown() const;
00118     
00119     // Implements ScatterPlot::setSymbolsShown().
00120     void setSymbolsShown(bool symbolsShown = true);
00121     
00122     // Implements ScatterPlot::symbol().
00123     PlotSymbolPtr symbol() const;
00124     
00125     // Implements ScatterPlot::setSymbol().
00126     void setSymbol(const PlotSymbol& symbol);
00127     
00128     
00129     // MaskedScatterPlot Methods //
00130     
00131     // Implements MaskedScatterPlot::maskedData().
00132     PlotMaskedPointDataPtr maskedData() const;
00133 
00134     // When underlying data is deleted
00135     void clearData();
00136 
00137     // Implements MaskedScatterPlot::maskedLinesShown().
00138     bool maskedLinesShown() const;
00139 
00140     // Implements MaskedScatterPlot::setMaskedLinesShown().
00141     void setMaskedLinesShown(bool linesShown = true);
00142 
00143     // Implements MaskedScatterPlot::maskedLine().
00144     PlotLinePtr maskedLine() const;
00145 
00146     // Implements MaskedScatterPlot::setMaskedLine().
00147     void setMaskedLine(const PlotLine& line);
00148 
00149     // Implements MaskedScatterPlot::maskedSymbolsShown().
00150     bool maskedSymbolsShown() const;
00151 
00152     // Implements MaskedScatterPlot::setMaskedSymbolsShown().
00153     void setMaskedSymbolsShown(bool symbolsShown = true);
00154 
00155     // Implements MaskedScatterPlot::maskedSymbol().
00156     PlotSymbolPtr maskedSymbol() const;
00157 
00158     // Implements MaskedScatterPlot::setMaskedSymbol().
00159     void setMaskedSymbol(const PlotSymbol& symbol);
00160     
00161     
00162     // ErrorPlot Methods //
00163     
00164     // Implements ErrorPlot::errorData().
00165     PlotErrorDataPtr errorData() const;
00166     
00167     // Implements ErrorPlot::errorLineShown().
00168     bool errorLineShown() const;
00169     
00170     // Implements ErrorPlot::setErrorLineShown().
00171     void setErrorLineShown(bool show = true);
00172     
00173     // Implements ErrorPlot::errorLine().
00174     PlotLinePtr errorLine() const;
00175     
00176     // Implements ErrorPlot::setErrorLine().
00177     void setErrorLine(const PlotLine& line);
00178     
00179     // Implements ErrorPlot::errorCapSize().
00180     unsigned int errorCapSize() const;
00181     
00182     // Implements ErrorPlot::setErrorCapSize().
00183     void setErrorCapSize(unsigned int capSize);
00184     
00185     
00186     // ColoredPlot Methods //
00187     
00188     // Implements ColoredPlot::binnedColorData().
00189     PlotBinnedDataPtr binnedColorData() const;
00190     
00191     // Implements ColoredPlot::colorForBin().
00192     PlotColorPtr colorForBin(unsigned int bin) const;
00193     
00194     // Implements ColoredPlot::setColorForBin().
00195     void setColorForBin(unsigned int bin, const PlotColorPtr color);
00196     
00197 protected:
00198     // Implements QPPlotItem::className().
00199     const String& className() const { return CLASS_NAME; }
00200     
00201     // Implements QPLayerItem::draw_().
00202 #if QWT_VERSION >= 0x060000
00203     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00204               const QwtScaleMap& yMap, const QRectF& canvasRect,
00205               unsigned int drawIndex, unsigned int drawCount) const;
00206 #else
00207     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00208               const QwtScaleMap& yMap, const QRect& canvasRect,
00209               unsigned int drawIndex, unsigned int drawCount) const;
00210 #endif
00211     
00212 private:
00213     // Data pointers.
00214     // <group>
00215     PlotPointDataPtr m_data;
00216     PlotMaskedPointDataPtr m_maskedData;
00217     PlotErrorDataPtr m_errorData;
00218     PlotBinnedDataPtr m_coloredData;
00219     // </group>
00220     
00221     // Customization objects.
00222     // <group>
00223     QPSymbol m_symbol;
00224     QPLine m_line;
00225     QPSymbol m_maskedSymbol;
00226     QPLine m_maskedLine;
00227     QPLine m_errorLine;
00228     unsigned int m_errorCap;
00229     // </group>
00230     
00231     // Binned colors.
00232     // <group>
00233     QList<QPColor*> m_colors;
00234     QList<QBrush> m_coloredBrushes;
00235     // </group>
00236     
00237 #if QWT_VERSION >= 0x060000
00238     // Make non-const symbol from m_symbol for colorized plots
00239     QPSymbol* coloredSymbol(const QColor& color) const;
00240 #endif
00241 
00242     // Updates the binned color brushes.
00243     void updateBrushes();
00244 };
00245 
00246 }
00247 
00248 #endif
00249 
00250 #endif /*QPSCATTERPLOT_H_*/
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1