casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
QPBarPlot.h
Go to the documentation of this file.
00001 //# QPBarPlot.h: Qwt implementation of generic BarPlot 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 QPBARPLOT_H_
00028 #define QPBARPLOT_H_
00029 
00030 #ifdef AIPS_HAS_QWT
00031 
00032 #include <graphics/GenericPlotter/Plot.h>
00033 #include <casaqt/QwtPlotter/QPPlotItem.qo.h>
00034 
00035 #include <casaqt/QwtPlotter/QPData.h>
00036 #include <casaqt/QwtPlotter/QPOptions.h>
00037 
00038 #include <casa/namespace.h>
00039 
00040 namespace casa {
00041 
00042 // Implementation of BarPlot for Qwt plotter.
00043 class QPBarPlot : public QPPlotItem, public BarPlot {
00044 public:
00045     // Static //
00046     
00047     // Convenient access to class name (QPBarPlot).
00048     static const String CLASS_NAME;
00049     
00050     
00051     // Non-Static //
00052     
00053     // Constructor which takes the data and an optional title.
00054     QPBarPlot(PlotPointDataPtr data, const String& title = "Qwt Bar Plot");
00055     
00056     // Copy constructor for generic BarPlot.
00057     QPBarPlot(const BarPlot& copy);
00058     
00059     // Destructor.
00060     ~QPBarPlot();
00061     
00062     
00063     // Include overloaded methods.
00064     using Plot::setLine;
00065     using BarPlot::setAreaFill;
00066     
00067     
00068     // PlotItem Methods //
00069     
00070     // Implements PlotItem::isValid().
00071     bool isValid() const;
00072     
00073     
00074     // QPPlotItem Methods //
00075     
00076     // Overrides QwtPlotItem::boundingRect();
00077     QwtDoubleRect boundingRect() const;
00078     
00079     // Overrides QwtPlotItem::legendItem().
00080     QWidget* legendItem() const;
00081     
00082     
00083     // Plot Methods //
00084     
00085     // Implements Plot::dataChanged().
00086     void dataChanged() { itemChanged(); }
00087     
00088     // Implements Plot::linesShown().
00089     bool linesShown() const;
00090 
00091     // Implements Plot::setLinesShown().
00092     void setLinesShown(bool linesShown = true);
00093 
00094     // Implements Plot::line().
00095     PlotLinePtr line() const;
00096 
00097     // Implements Plot::setLine().
00098     void setLine(const PlotLine& line);
00099     
00100     
00101     // BarPlot Methods //
00102     
00103     // Implements BarPlot::pointData().
00104     PlotPointDataPtr pointData() const;
00105 
00106     // Implements BarPlot::areaIsFilled().
00107     bool areaIsFilled() const;
00108     
00109     // Implements BarPlot::setAreaFilled().
00110     void setAreaFilled(bool fill = true);
00111     
00112     // Implements BarPlot::areaFill().
00113     PlotAreaFillPtr areaFill() const;
00114 
00115     // Implements BarPlot::setAreaFill().
00116     void setAreaFill(const PlotAreaFill& areaFill);
00117     
00118 protected:
00119     // Implements QPPlotItem::className().
00120     const String& className() const { return CLASS_NAME; }
00121     
00122     // Implements QPLayerItem::draw_().
00123     void draw_(QPainter* painter, const QwtScaleMap& xMap,
00124               const QwtScaleMap& yMap, const QRect& canvasRect,
00125               unsigned int drawIndex, unsigned int drawCount) const;
00126     
00127 private:
00128     QPPointData m_data;    // Data
00129     double m_barWidth;     // Bar width
00130     QPLine m_line;         // Line
00131     QPAreaFill m_areaFill; // Area fill
00132     
00133     
00134     // Calculates the bar width from the data.  Currently only set to happen
00135     // once when the data is set.
00136     void calculateBarWidth();
00137 };
00138 
00139 }
00140 
00141 #endif
00142 
00143 #endif /*QPBARPLOT_H_*/