casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QPScatterPlot.h
Go to the documentation of this file.
1 //# QPScatterPlot.h: Qwt implementation of generic ScatterPlot 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 QPSCATTERPLOT_H_
28 #define QPSCATTERPLOT_H_
29 
30 #ifdef AIPS_HAS_QWT
31 
35 
36 #include <QObject>
37 
38 namespace casa {
39 
40 // Implementation of MaskedPlot, ErrorPlot, and ColoredPlot for Qwt plotter.
41 class QPScatterPlot : public QPPlotItem, public MaskedScatterPlot,
42  public ErrorPlot, public ColoredPlot {
43 public:
44  // Static //
45 
46  // Convenient access to class name (QPScatterPlot).
47  const static casacore::String CLASS_NAME;
48 
49  // Non-Static //
50 
51  // Constructor which takes the data (and determines its type) and an
52  // optional title.
53  QPScatterPlot(PlotPointDataPtr data, const casacore::String& title = "Scatter Plot");
54 
55  // Copy constructor for generic ScatterPlot.
56  QPScatterPlot(const ScatterPlot& copy);
57 
58  // Destructor.
59  ~QPScatterPlot();
60 
61 
62  // Include overloaded methods.
63  using Plot::setLine;
68 
69 
70  // PlotItem Methods //
71 
72  // Implements PlotItem::isValid().
73  bool isValid() const;
74 
75 
76  // QPPlotItem Methods //
77 
78  // Overrides QPPlotItem::shouldDraw().
79  bool shouldDraw() const;
80 
81  // Overrides QwtPlotItem::boundingRect();
82  QwtDoubleRect boundingRect() const;
83 
84 #if QWT_VERSION >= 0x060000
85  // implements QwtPlotItem::legendIcon
86  QwtGraphic legendIcon(int index, const QSizeF& size) const;
87 #else
88  // Overrides QwtPlotItem::legendItem().
89  QWidget* legendItem() const;
90 #endif
91 
92 
93  // Plot Methods //
94 
95  // Implements Plot::dataChanged().
96  void dataChanged() { itemChanged(); }
97 
98  // Implements Plot::linesShown().
99  bool linesShown() const;
100 
101  // Implements Plot::setLinesShown().
102  void setLinesShown(bool linesShown = true);
103 
104  // Implements Plot::line().
105  PlotLinePtr line() const;
106 
107  // Implements Plot::setLine().
108  void setLine(const PlotLine& line);
109 
110  // Implements ScatterPlot::linesStep() and setLinesStep().
111  inline bool linesStep() const { return m_step; }
112  inline void setLinesStep(bool linesStep = true) { m_step = linesStep; }
113 
114  // ScatterPlot Methods //
115 
116  // Implements ScatterPlot::pointData().
117  PlotPointDataPtr pointData() const;
118 
119  // Implements ScatterPlot::symbolsShown().
120  bool symbolsShown() const;
121 
122  // Implements ScatterPlot::setSymbolsShown().
123  void setSymbolsShown(bool symbolsShown = true);
124 
125  // Implements ScatterPlot::symbol().
126  PlotSymbolPtr symbol() const;
127 
128  // Implements ScatterPlot::setSymbol().
129  void setSymbol(const PlotSymbol& symbol);
130 
131 
132  // MaskedScatterPlot Methods //
133 
134  // Implements MaskedScatterPlot::maskedData().
135  PlotMaskedPointDataPtr maskedData() const;
136 
137  // When underlying data is deleted
138  void clearData();
139 
140  // Implements MaskedScatterPlot::maskedLinesShown().
141  bool maskedLinesShown() const;
142 
143  // Implements MaskedScatterPlot::setMaskedLinesShown().
144  void setMaskedLinesShown(bool linesShown = true);
145 
146  // Implements MaskedScatterPlot::maskedLine().
147  PlotLinePtr maskedLine() const;
148 
149  // Implements MaskedScatterPlot::setMaskedLine().
150  void setMaskedLine(const PlotLine& line);
151 
152  // Implements MaskedScatterPlot::maskedLinesStep() and setMaskedLinesStep().
153  inline bool maskedLinesStep() const { return m_maskedStep; }
154  inline void setMaskedLinesStep(bool linesStep = true) { m_maskedStep = linesStep; }
155 
156  // Implements MaskedScatterPlot::maskedSymbolsShown().
157  bool maskedSymbolsShown() const;
158 
159  // Implements MaskedScatterPlot::setMaskedSymbolsShown().
160  void setMaskedSymbolsShown(bool symbolsShown = true);
161 
162  // Implements MaskedScatterPlot::maskedSymbol().
163  PlotSymbolPtr maskedSymbol() const;
164 
165  // Implements MaskedScatterPlot::setMaskedSymbol().
166  void setMaskedSymbol(const PlotSymbol& symbol);
167 
168 
169  // ErrorPlot Methods //
170 
171  // Implements ErrorPlot::errorData().
172  PlotErrorDataPtr errorData() const;
173 
174  // Implements ErrorPlot::errorLineShown().
175  bool errorLineShown() const;
176 
177  // Implements ErrorPlot::setErrorLineShown().
178  void setErrorLineShown(bool show = true);
179 
180  // Implements ErrorPlot::errorLine().
181  PlotLinePtr errorLine() const;
182 
183  // Implements ErrorPlot::setErrorLine().
184  void setErrorLine(const PlotLine& line);
185 
186  // Implements ErrorPlot::errorCapSize().
187  unsigned int errorCapSize() const;
188 
189  // Implements ErrorPlot::setErrorCapSize().
190  void setErrorCapSize(unsigned int capSize);
191 
192 
193  // ColoredPlot Methods //
194 
195  // Implements ColoredPlot::binnedColorData().
196  PlotBinnedDataPtr binnedColorData() const;
197 
198  // Implements ColoredPlot::colorForBin().
199  PlotColorPtr colorForBin(unsigned int bin) const;
200 
201  // Implements ColoredPlot::setColorForBin().
202  void setColorForBin(unsigned int bin, const PlotColorPtr color);
203 
204 protected:
205  // Implements QPPlotItem::className().
206  const casacore::String& className() const { return CLASS_NAME; }
207 
208  // Implements QPLayerItem::draw_().
209 #if QWT_VERSION >= 0x060000
210  void draw_(QPainter* painter, const QwtScaleMap& xMap,
211  const QwtScaleMap& yMap, const QRectF& canvasRect,
212  unsigned int drawIndex, unsigned int drawCount) const;
213 #else
214  void draw_(QPainter* painter, const QwtScaleMap& xMap,
215  const QwtScaleMap& yMap, const QRect& canvasRect,
216  unsigned int drawIndex, unsigned int drawCount) const;
217 #endif
218 
219 private:
220  // casacore::Data pointers.
221  // <group>
222  PlotPointDataPtr m_data;
223  PlotMaskedPointDataPtr m_maskedData;
224  PlotErrorDataPtr m_errorData;
225  PlotBinnedDataPtr m_coloredData;
226  // </group>
227 
228  // Customization objects.
229  // <group>
230  QPSymbol m_symbol;
231  QPLine m_line;
232  bool m_step;
233  QPSymbol m_maskedSymbol;
234  QPLine m_maskedLine;
235  QPLine m_errorLine;
236  unsigned int m_errorCap;
237  bool m_maskedStep;
238  // </group>
239 
240  // Binned colors.
241  // <group>
242  QList<QPColor*> m_colors;
243  QList<QBrush> m_coloredBrushes;
244  // </group>
245 
246 #if QWT_VERSION >= 0x060000
247  // Make non-const symbol from m_symbol for colorized plots
248  QPSymbol* coloredSymbol(const QColor& color) const;
249 #endif
250 
251  // Updates the binned color brushes.
252  void updateBrushes();
253 };
254 
255 }
256 
257 #endif
258 
259 #endif /*QPSCATTERPLOT_H_*/
casacore::CountedPtr< PlotColor > PlotColorPtr
Definition: PlotOptions.h:195
StatsData< AccumType > copy(const StatsData< AccumType > &stats)
casacore::CountedPtr< PlotLine > PlotLinePtr
Definition: PlotOptions.h:446
virtual void setSymbol(const PlotSymbolPtr symbol)
Definition: PlotShape.h:356
virtual void setMaskedSymbol(const PlotSymbol &symbol)=0
Sets the symbols for masked points to the given.
size_t size() const
void show(const variant &v)
ScatterPlot
Definition: Plot.h:598
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
virtual void setSymbol(const PlotSymbol &symbol)=0
Sets the plot symbols to the given symbol.
casacore::CountedPtr< PlotSymbol > PlotSymbolPtr
Definition: PlotOptions.h:604
virtual void setMaskedLine(const PlotLine &line)=0
Sets the lines for masked points to the given.
virtual void setErrorLine(const PlotLine &line)=0
Sets the line used to draw the error bars.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the color(i.e.,"000000"for black) and
virtual void setLine(const PlotLine &line)=0
Sets the plot lines to the given line.