00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef SIMPLEPLOTTER_H_
00028 #define SIMPLEPLOTTER_H_
00029
00030 #include <graphics/GenericPlotter/PlotFactory.h>
00031
00032 #include <casa/Arrays/Matrix.h>
00033
00034 namespace casa {
00035
00036
00037
00038
00039 class SimplePlotter {
00040 public:
00041
00042 SimplePlotter(PlotFactoryPtr factory);
00043
00044
00045 ~SimplePlotter();
00046
00047
00048
00049
00050
00051 PlotFactoryPtr getFactory() { return m_factory; }
00052
00053
00054 PlotterPtr getPlotter() { return m_plotter; }
00055
00056
00057 PlotCanvasPtr getCanvas() { return m_canvas; }
00058
00059
00060 PlotLinePtr getLine() { return m_line; }
00061
00062
00063 PlotSymbolPtr getSymbol() { return m_symbol; }
00064
00065
00066 PlotAreaFillPtr getAreaFill() { return m_areaFill; }
00067
00068
00069
00070
00071
00072 int execLoop();
00073
00074
00075
00076 void holdDrawing();
00077 void releaseDrawing();
00078
00079
00080
00081
00082
00083
00084 void setWindowTitle(const String& windowTitle);
00085
00086
00087 void setCanvasTitle(const String& canvasTitle);
00088
00089
00090 void setAxesLabels(const String& xLabel, const String& yLabel);
00091
00092
00093 void showCartesianAxes(bool show = true);
00094
00095
00096 void setXAxisRange(double from, double to);
00097
00098
00099 void setYAxisRange(double from, double to);
00100
00101
00102
00103 void setAxesAutoRescale(bool on = true);
00104
00105
00106 void rescaleAxes();
00107
00108
00109
00110
00111
00112 void showLines(bool showLines = true);
00113
00114
00115 void showSymbols(bool showSymbols = true);
00116
00117
00118
00119 void setLine(const String& color,
00120 PlotLine::Style style = PlotLine::SOLID, double width = 1.0);
00121
00122
00123 void setSymbol(PlotSymbol::Symbol symbol, const String& color = "blue",
00124 double size = 5, bool outline = true);
00125
00126
00127
00128 void setAreaFill(const String& color,
00129 PlotAreaFill::Pattern pattern = PlotAreaFill::FILL);
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 ScatterPlotPtr plotxy(double*& x, double*& y, unsigned int n,
00141 bool overplot = true);
00142 ScatterPlotPtr plotxy(float*& x, float*& y, unsigned int n,
00143 bool overplot = true);
00144 ScatterPlotPtr plotxy(int*& x, int*& y, unsigned int n,
00145 bool overplot = true);
00146
00147 ScatterPlotPtr plotxy(Vector<double>& x, Vector<double>& y,
00148 bool overplot = true);
00149 ScatterPlotPtr plotxy(Vector<float>& x, Vector<float>& y,
00150 bool overplot = true);
00151 ScatterPlotPtr plotxy(Vector<int>& x, Vector<int>& y,
00152 bool overplot = true);
00153
00154 ScatterPlotPtr plotxy(PlotPointDataPtr data, bool overplot = true);
00155
00156 ScatterPlotPtr ploty(double*& y, unsigned int n, bool overplot = true);
00157 ScatterPlotPtr ploty(float*& y, unsigned int n, bool overplot = true);
00158 ScatterPlotPtr ploty(int*& y, unsigned int n, bool overplot = true);
00159
00160 ScatterPlotPtr ploty(Vector<double>& y, bool overplot = true);
00161 ScatterPlotPtr ploty(Vector<float>& y, bool overplot = true);
00162 ScatterPlotPtr ploty(Vector<int>& y, bool overplot = true);
00163
00164 ScatterPlotPtr ploty(PlotPointDataPtr data, bool overplot = true);
00165
00166
00167
00168
00169
00170 BarPlotPtr barPlot(double*& x, double*& y, unsigned int n,
00171 bool overplot = false);
00172 BarPlotPtr barPlot(float*& x, float*& y, unsigned int n,
00173 bool overplot = false);
00174 BarPlotPtr barPlot(int*& x, int*& y, unsigned int n,
00175 bool overplot = false);
00176
00177 BarPlotPtr barPlot(Vector<double>& x, Vector<double>& y,
00178 bool overplot = false);
00179 BarPlotPtr barPlot(Vector<float>& x, Vector<float>& y,
00180 bool overplot = false);
00181 BarPlotPtr barPlot(Vector<int>& x, Vector<int>& y,
00182 bool overplot = false);
00183
00184 BarPlotPtr barPlot(PlotPointDataPtr data, bool overplot = false);
00185
00186
00187
00188
00189
00190 BarPlotPtr histogramPlot(double*& data, unsigned int n,
00191 unsigned int numBins, bool overplot= false);
00192 BarPlotPtr histogramPlot(float*& data, unsigned int n,
00193 unsigned int numBins, bool overplot= false);
00194 BarPlotPtr histogramPlot(int*& data, unsigned int n,
00195 unsigned int numBins, bool overplot= false);
00196 BarPlotPtr histogramPlot(Vector<double>& data, unsigned int numBins,
00197 bool overplot = false);
00198 BarPlotPtr histogramPlot(Vector<float>& data, unsigned int numBins,
00199 bool overplot = false);
00200 BarPlotPtr histogramPlot(Vector<int>& data, unsigned int numBins,
00201 bool overplot = false);
00202
00203 BarPlotPtr histogramPlot(PlotSingleDataPtr data, unsigned int numBins,
00204 bool overplot = false);
00205
00206
00207
00208
00209
00210 RasterPlotPtr rasterPlot(Matrix<double>& data, bool overplot = false);
00211 RasterPlotPtr rasterPlot(Matrix<float>& data, bool overplot = false);
00212 RasterPlotPtr rasterPlot(Matrix<int>& data, bool overplot = false);
00213 RasterPlotPtr rasterPlot(Matrix<uInt>& data, bool overplot = false);
00214 RasterPlotPtr rasterPlot(Matrix<double>& data, double fromX, double toX,
00215 double fromY, double toY, bool overplot = false);
00216 RasterPlotPtr rasterPlot(Matrix<float>& data, double fromX, double toX,
00217 double fromY, double toY, bool overplot = false);
00218 RasterPlotPtr rasterPlot(Matrix<int>& data, double fromX, double toX,
00219 double fromY, double toY, bool overplot = false);
00220 RasterPlotPtr rasterPlot(Matrix<uInt>& data, double fromX, double toX,
00221 double fromY, double toY, bool overplot = false);
00222 RasterPlotPtr rasterPlot(PlotRasterDataPtr data, bool overplot = false);
00223
00224 RasterPlotPtr contourPlot(Matrix<double>& data, Vector<double>& contours,
00225 bool overplot = false);
00226 RasterPlotPtr contourPlot(Matrix<float>& data, Vector<float>& contours,
00227 bool overplot = false);
00228 RasterPlotPtr contourPlot(Matrix<int>& data, Vector<int>& contours,
00229 bool overplot = false);
00230 RasterPlotPtr contourPlot(Matrix<uInt>& data, Vector<uInt>& contours,
00231 bool overplot = false);
00232 RasterPlotPtr contourPlot(Matrix<double>& data, double fromX, double toX,
00233 double fromY,double toY,Vector<double>& contours,
00234 bool overplot = false);
00235 RasterPlotPtr contourPlot(Matrix<float>& data, double fromX, double toX,
00236 double fromY,double toY, Vector<float>& contours,
00237 bool overplot = false);
00238 RasterPlotPtr contourPlot(Matrix<int>& data, double fromX, double toX,
00239 double fromY, double toY, Vector<int>& contours,
00240 bool overplot = false);
00241 RasterPlotPtr contourPlot(Matrix<uInt>& data, double fromX, double toX,
00242 double fromY, double toY, Vector<uInt>& contours,
00243 bool overplot = false);
00244 RasterPlotPtr contourPlot(PlotRasterDataPtr data, vector<double>& contours,
00245 bool overplot = false);
00246
00247 RasterPlotPtr spectrogram(Matrix<double>& data, bool overplt = false);
00248 RasterPlotPtr spectrogram(Matrix<float>& data, bool overplot = false);
00249 RasterPlotPtr spectrogram(Matrix<int>& data, bool overplot = false);
00250 RasterPlotPtr spectrogram(Matrix<uInt>& data, bool overplot = false);
00251 RasterPlotPtr spectrogram(Matrix<double>& data, double fromX, double toX,
00252 double fromY, double toY, bool overplot = false);
00253 RasterPlotPtr spectrogram(Matrix<float>& data, double fromX, double toX,
00254 double fromY, double toY, bool overplot = false);
00255 RasterPlotPtr spectrogram(Matrix<int>& data, double fromX, double toX,
00256 double fromY, double toY, bool overplot = false);
00257 RasterPlotPtr spectrogram(Matrix<uInt>& data, double fromX, double toX,
00258 double fromY, double toY, bool overplot = false);
00259 RasterPlotPtr spectrogram(PlotRasterDataPtr data, bool overplot = false);
00260
00261 RasterPlotPtr spectrogram(Matrix<double>& d, Vector<double>& contours,
00262 bool overplot = false);
00263 RasterPlotPtr spectrogram(Matrix<float>& data,Vector<float>& contours,
00264 bool overplot = false);
00265 RasterPlotPtr spectrogram(Matrix<int>& data, Vector<int>& contours,
00266 bool overplot = false);
00267 RasterPlotPtr spectrogram(Matrix<uInt>& data, Vector<uInt>& contours,
00268 bool overplot = false);
00269 RasterPlotPtr spectrogram(Matrix<double>& d, double fromX, double toX,
00270 double fromY,double toY,Vector<double>& contours,
00271 bool overplot = false);
00272 RasterPlotPtr spectrogram(Matrix<float>& data,double fromX,double toX,
00273 double fromY,double toY, Vector<float>& contours,
00274 bool overplot = false);
00275 RasterPlotPtr spectrogram(Matrix<int>& data, double fromX, double toX,
00276 double fromY, double toY, Vector<int>& contours,
00277 bool overplot = false);
00278 RasterPlotPtr spectrogram(Matrix<uInt>& data, double fromX,double toX,
00279 double fromY, double toY, Vector<uInt>& contours,
00280 bool overplot = false);
00281 RasterPlotPtr spectrogram(PlotRasterDataPtr data, vector<double>& contours,
00282 bool overplot = false);
00283
00284
00285
00286 PlotPointPtr plotPoint(double x, double y);
00287
00288
00289
00290
00291
00292 PlotAnnotationPtr annotation(double x, double y, const String& text);
00293
00294
00295
00296 PlotShapeRectanglePtr rectangle(double left, double top,
00297 double right, double bottom);
00298
00299
00300
00301
00302 PlotShapeEllipsePtr ellipse(double centerX, double centerY,
00303 double xRadius, double yRadius);
00304 PlotShapeEllipsePtr ellipse(double x, double y, double radius);
00305
00306
00307
00308 PlotShapeLinePtr xLine(double value);
00309
00310
00311 PlotShapeLinePtr yLine(double value);
00312
00313
00314 PlotShapeArrowPtr arrow(double xFrom, double yFrom,
00315 double xTo, double yTo);
00316
00317
00318 PlotShapeArrowPtr lineSegment(double xFrom, double yFrom,
00319 double xTo, double yTo);
00320
00321
00322
00323
00324
00325 void clear();
00326
00327
00328 void clearPoints();
00329
00330
00331
00332
00333
00334
00335 void showDefaultHandTools(bool show = true);
00336
00337
00338
00339 void showDefaultExportTools(bool show = true);
00340
00341
00342
00343
00344 vector<PlotRegion> allSelectedRegions();
00345
00346
00347 void clearSelectedRegions();
00348
00349
00350
00351
00352
00353
00354
00355 String fileChooserDialog(const String& title = "File Chooser",
00356 const String& directory = "");
00357
00358
00359
00360
00361 bool exportPDF(const String& location, bool highQuality = false,
00362 int dpi = -1);
00363
00364
00365
00366
00367 bool exportPS(const String& location, bool highQuality = false,
00368 int dpi = -1);
00369
00370
00371
00372
00373 bool exportJPG(const String& location, bool highQuality = false,
00374 int width = -1, int height = -1);
00375
00376
00377
00378
00379 bool exportPNG(const String& location, bool highQuality = false,
00380 int width = -1, int height = -1);
00381
00382
00383 bool exportToFile(const PlotExportFormat& format);
00384
00385 private:
00386
00387 PlotFactoryPtr m_factory;
00388
00389
00390 PlotterPtr m_plotter;
00391
00392
00393 PlotCanvasPtr m_canvas;
00394
00395
00396 PlotStandardMouseToolGroupPtr m_mouseTools;
00397
00398
00399 vector<PlotPointPtr> m_accumulatedPoints;
00400
00401
00402 PlotLinePtr m_line;
00403
00404
00405 PlotSymbolPtr m_symbol;
00406
00407
00408 PlotAreaFillPtr m_areaFill;
00409 };
00410
00411 typedef CountedPtr<SimplePlotter> SimplePlotterPtr;
00412
00413 }
00414
00415 #endif