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