casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QPBarPlot.h
Go to the documentation of this file.
1 //# QPBarPlot.h: Qwt implementation of generic BarPlot class.
2 //# Copyright (C) 2008
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 #ifndef QPBARPLOT_H_
28 #define QPBARPLOT_H_
29 
30 #ifdef AIPS_HAS_QWT
31 
34 
37 
38 namespace casa {
39 
40 // Implementation of BarPlot for Qwt plotter.
41 class QPBarPlot : public QPPlotItem, public BarPlot {
42 public:
43  // Static //
44 
45  // Convenient access to class name (QPBarPlot).
46  static const casacore::String CLASS_NAME;
47 
48 
49  // Non-Static //
50 
51  // Constructor which takes the data and an optional title.
52  QPBarPlot(PlotPointDataPtr data, const casacore::String& title = "Qwt Bar Plot");
53 
54  // Copy constructor for generic BarPlot.
55  QPBarPlot(const BarPlot& copy);
56 
57  // Destructor.
58  ~QPBarPlot();
59 
60 
61  // Include overloaded methods.
62  using Plot::setLine;
64 
65 
66  // PlotItem Methods //
67 
68  // Implements PlotItem::isValid().
69  bool isValid() const;
70 
71 
72  // QPPlotItem Methods //
73 
74  // Overrides QwtPlotItem::boundingRect();
75  QwtDoubleRect boundingRect() const;
76 
77 #if QWT_VERSION < 0x060000
78  // Overrides QwtPlotItem::legendItem().
79  QWidget* legendItem() const;
80 #endif
81 
82 
83  // Plot Methods //
84 
85  // Implements Plot::dataChanged().
86  void dataChanged() { itemChanged(); }
87 
88  // Implements Plot::linesShown().
89  bool linesShown() const;
90 
91  // Implements Plot::setLinesShown().
92  void setLinesShown(bool linesShown = true);
93 
94  // Implements Plot::line().
95  PlotLinePtr line() const;
96 
97  // Implements Plot::setLine().
98  void setLine(const PlotLine& line);
99 
100 
101  // BarPlot Methods //
102 
103  // Implements BarPlot::pointData().
104  PlotPointDataPtr pointData() const;
105 
106  // Implements BarPlot::areaIsFilled().
107  bool areaIsFilled() const;
108 
109  // Implements BarPlot::setAreaFilled().
110  void setAreaFilled(bool fill = true);
111 
112  // Implements BarPlot::areaFill().
113  PlotAreaFillPtr areaFill() const;
114 
115  // Implements BarPlot::setAreaFill().
116  void setAreaFill(const PlotAreaFill& areaFill);
117 
118 protected:
119  // Implements QPPlotItem::className().
120  const casacore::String& className() const { return CLASS_NAME; }
121 
122  // Implements QPLayerItem::draw_().
123 #if QWT_VERSION >= 0x060000
124  void draw_(QPainter* painter, const QwtScaleMap& xMap,
125  const QwtScaleMap& yMap, const QRectF& canvasRect,
126  unsigned int drawIndex, unsigned int drawCount) const;
127 #else
128  void draw_(QPainter* painter, const QwtScaleMap& xMap,
129  const QwtScaleMap& yMap, const QRect& canvasRect,
130  unsigned int drawIndex, unsigned int drawCount) const;
131 #endif
132 
133 private:
134  QPPointData m_data; // Data
135  double m_barWidth; // Bar width
136  QPLine m_line; // Line
137  QPAreaFill m_areaFill; // Area fill
138 
139 
140  // Calculates the bar width from the data. Currently only set to happen
141  // once when the data is set.
142  void calculateBarWidth();
143 };
144 
145 }
146 
147 #endif
148 
149 #endif /*QPBARPLOT_H_*/
casacore::CountedPtr< PlotAreaFill > PlotAreaFillPtr
Definition: PlotOptions.h:364
virtual void setAreaFill(const PlotAreaFill &areaFill)=0
Sets the area fill used for the bars to the given.
StatsData< AccumType > copy(const StatsData< AccumType > &stats)
casacore::CountedPtr< PlotLine > PlotLinePtr
Definition: PlotOptions.h:446
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual void setLine(const PlotLine &line)=0
Sets the plot lines to the given line.