casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TBPlotCanvas.qo.h
Go to the documentation of this file.
1 //# TBPlotCanvas.qo.h: Canvas for data plotting using qwt.
2 //# Copyright (C) 2005
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 TBPLOTCANVAS_H_
28 #define TBPLOTCANVAS_H_
29 
30 #include <casaqt/QtBrowser/TBPlotCanvas.ui.h>
34 
36 
37 #include <casa/BasicSL/String.h>
38 
39 #include <vector>
40 
41 namespace casa {
42 
43 //# Forward Declarations
44 class TBPlotData;
45 class TBLocateParams;
46 
47 // <summary>
48 // casacore::Format for the curves on the plot canvas.
49 // </summary>
50 //
51 // <synopsis>
52 // A TBPlotFormat specifies how to display a plot curve. The format includes
53 // a PlotLine and a PlotSymbol.
54 // </synopsis>
55 
56 class TBPlotFormat {
57 public:
58  // Constructor that takes a factory to build the line and symbol.
60 
61  ~TBPlotFormat();
62 
63 
64  // Sets the curve style using the given QString name.
65  void setCurveStyle(QString str);
66 
67  // Sets the point style using the given QString name.
68  void setPointStyle(QString str);
69 
70  // Line to use with the plot
72 
73  // Symbol to use with the plot
75 
76  /*
77  // Returns a QwtSymbol using the format's point style, size, and color.
78  QwtSymbol getSymbol();
79 
80  // Curve style.
81  QwtPlotCurve::CurveStyle curveStyle;
82 
83  // Point style.
84  QwtSymbol::Style pointStyle;
85 
86  // Point color.
87  QColor color;
88 
89  // Point size.
90  // <group>
91  int size1;
92  int size2;
93  // </group>
94  */
95 };
96 
97 
98 // <summary>
99 // Canvas for data plotting using a given plotting implementation.
100 // </summary>
101 //
102 // <synopsis>
103 // TBPlotCanvas uses and controls a plotting implementation canvas. If the
104 // implementation is Qt, it is embedded in the TBPlotCanvas; otherwise it is
105 // assumed to be in a separate window.
106 // </synopsis>
107 
108 class TBPlotCanvas : public QWidget, Ui::PlotCanvas,
109  public PlotSelectEventHandler {
110  Q_OBJECT
111 
112 public:
113  // Constructor with a factory.
115 
116  ~TBPlotCanvas();
117 
118 
119  // Sets the X-axis title to the given String.
120  void setXAxisTitle(casacore::String title);
121 
122  // Sets the Y-axis title to the given String.
123  void setYAxisTitle(casacore::String title);
124 
125  // Sets which grids are shown on the canvas.
126  void setShownGrids(bool xMaj, bool xMin, bool yMaj, bool yMin);
127 
128  // Sets the x axis to display values as dates.
129  void setXAxisDate(bool date = true, bool mjsec = true);
130 
131  // Sets the y axis to display values as dates.
132  void setYAxisDate(bool date = true, bool mjsec = true);
133 
134  // Returns the name of the current table being plotted.
136 
137  // Sets the name of the current table being plotted.
138  void setTable(casacore::String table);
139 
140  // Returns the current number of plots currently on the canvas.
141  int getNumPlots();
142 
143 
144  // Returns the data corresponding to the current plots.
145  std::vector<TBPlotData*> allData();
146 
147  // Implements PlotSelectEventHandler::handleSelect().
148  void handleSelect(const PlotSelectEvent& event);
149 
150  // Plots the given data. If overplot is true all old plots
151  // are kept as well, otherwise the old plots are cleared first.
152  // See PlotCanvas::plot().
153  void plot(TBPlotData* data, const TBPlotFormat& format,
154  bool overplot = false);
155 
156  // Exports the PlotCanvas to an image in the given format at the given
157  // location and returns whether the operation succeeded or not.
159 
160  // If there is a rectangle shape from a user-selected region, clear it
161  // from the canvas.
162  void clearSelectedRectangle();
163 
164  // If there is a current user-selected region, return it. Otherwise
165  // behavior is undefined.
167 
168 public slots:
169  // Clears all current plots and hides the two axes.
170  void clearAndHideAxes();
171 
172 signals:
173  // Signal that is emitted whenever the user selects a region, or the
174  // currently selected region is cleared. If selected is true, then the
175  // user selected a region and a rectangle is now on the canvas. If
176  // selected is false, then there is no longer a current selected region.
177  void regionSelected(bool selected);
178 
179 private:
180  // Plotter factory
182 
183  // Plotter
185 
186  // Plot canvas
188 
189  // Holds the name of the current table being plotted.
191 
192  // Currently selected region, or NULL if there is none.
193  PlotShapeRectanglePtr selectedRegion;
194 
195  // Current data.
196  std::vector<TBPlotData*> data;
197 
198 private slots:
199  // Slot for clearing all the internal tracking of current plots.
200  void clearPlots();
201 };
202 
203 }
204 
205 #endif /* TBPLOTCANVAS_H_ */
void clearAndHideAxes()
Clears all current plots and hides the two axes.
TBPlotFormat(PlotFactoryPtr factory)
Constructor that takes a factory to build the line and symbol.
Event for when the user selects a region on a plot canvas with the mouse.
Definition: PlotEvent.h:53
void setYAxisDate(bool date=true, bool mjsec=true)
Sets the y axis to display values as dates.
PlotterPtr plotter
Plotter.
void regionSelected(bool selected)
Signal that is emitted whenever the user selects a region, or the currently selected region is cleare...
PlotSymbolPtr symbol
Symbol to use with the plot.
Convenience class for a casacore::String/bool tuple.
Definition: TBConstants.h:93
std::vector< TBPlotData * > data
Current data.
void setXAxisTitle(casacore::String title)
Sets the X-axis title to the given String.
void setShownGrids(bool xMaj, bool xMin, bool yMaj, bool yMin)
Sets which grids are shown on the canvas.
casacore::Data for plotting.
Definition: TBPlotter.qo.h:94
void setPointStyle(QString str)
Sets the point style using the given QString name.
Base class for a handler for PlotSelectEvent.
Canvas for data plotting using a given plotting implementation.
void setTable(casacore::String table)
Sets the name of the current table being plotted.
casacore::String currentTable
Holds the name of the current table being plotted.
PlotRegion currentSelection()
If there is a current user-selected region, return it.
PlotShapeRectanglePtr selectedRegion
Currently selected region, or NULL if there is none.
casacore::Format for the curves on the plot canvas.
std::vector< TBPlotData * > allData()
Returns the data corresponding to the current plots.
Result exportToImage(casacore::String format, casacore::String location)
Exports the PlotCanvas to an image in the given format at the given location and returns whether the ...
void setCurveStyle(QString str)
Sets the curve style using the given QString name.
casacore::String getCurrentTable()
Returns the name of the current table being plotted.
void clearPlots()
Slot for clearing all the internal tracking of current plots.
int getNumPlots()
Returns the current number of plots currently on the canvas.
PlotLinePtr line
Line to use with the plot.
void plot(TBPlotData *data, const TBPlotFormat &format, bool overplot=false)
Plots the given data.
void setYAxisTitle(casacore::String title)
Sets the Y-axis title to the given String.
std::string date()
get the current data
PlotFactoryPtr factory
Plotter factory.
void setXAxisDate(bool date=true, bool mjsec=true)
Sets the x axis to display values as dates.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
PlotCanvasPtr canvas
Plot canvas.
TBPlotCanvas(PlotFactoryPtr factory)
Constructor with a factory.
A PlotRegion is basically just a wrapper for two PlotCoordinates: an upper left coordinate and a lowe...
Definition: PlotOptions.h:682
void clearSelectedRectangle()
If there is a rectangle shape from a user-selected region, clear it from the canvas.
void handleSelect(const PlotSelectEvent &event)
Implements PlotSelectEventHandler::handleSelect().