Analysis/TimeSeries/plotTS.cpp

Go to the documentation of this file.
00001 #include <qapplication.h>
00002 #include <qwt_plot.h>
00003 #include <qwt_plot_marker.h>
00004 #include <qwt_plot_curve.h>
00005 #include <qwt_legend.h>
00006 #include <qwt_data.h>
00007 #include <qwt_text.h>
00008 #include <math.h>
00009 #include <qdialog.h>
00010 
00011 #include <qcolor.h>
00012 #include "plotTS.h"
00013 
00014 /*
00015 class PlotTS : public QwtPlot
00016 {
00017 public:
00018     PlotTS(const char*, const char*, const char*, const char*, double *, double *, int);
00019 };
00020 */
00021 
00022 PlotTS::PlotTS(const char *plotTitle, const char *xTitle, const char *yTitle, const char *legend, double *xVal, double *yVal, int nPts)
00023 {
00024         //qWarning("class\n");
00025         QColor color(255, 255, 255);
00026         setCanvasBackground(color);
00027     setTitle(plotTitle);
00028     insertLegend(new QwtLegend(), QwtPlot::RightLegend);
00029 
00030     // Set axis titles
00031     setAxisTitle(xBottom, xTitle);
00032     setAxisTitle(yLeft, yTitle);
00033     
00034     // Insert new curves
00035     QwtPlotCurve *cSin = new QwtPlotCurve(legend);
00036 #if QT_VERSION >= 0x040000
00037     cSin->setRenderHint(QwtPlotItem::RenderAntialiased);
00038 #endif
00039     cSin->setPen(QPen(Qt::blue));
00040     cSin->attach(this);
00041 
00042     // Create sin and cos data
00043     //const int nPoints = 100;
00044     //cSin->setData(SimpleData(::sin, nPoints));
00045     //cCos->setData(SimpleData(::cos, nPoints));
00046 
00047         cSin->setData(xVal, yVal, nPts);
00048 
00049     // Insert markers
00050    /* 
00051     //  ...a horizontal line at y = 0...
00052     QwtPlotMarker *mY = new QwtPlotMarker();
00053     mY->setLabel(QString::fromLatin1("y = 0"));
00054     mY->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
00055     mY->setLineStyle(QwtPlotMarker::HLine);
00056     mY->setYValue(0.0);
00057     mY->attach(this);
00058 
00059     //  ...a vertical line at x = 2 * pi
00060     QwtPlotMarker *mX = new QwtPlotMarker();
00061     mX->setLabel(QString::fromLatin1("x = 2 pi"));
00062     mX->setLabelAlignment(Qt::AlignRight|Qt::AlignTop);
00063     mX->setLineStyle(QwtPlotMarker::VLine);
00064     mX->setXValue(6.284);
00065     mX->attach(this);
00066 */
00067         //parent->show();
00068         //qWarning("Done\n");
00069 }
00070 /*
00071 int main(int argc, char **argv)
00072 {
00073     QApplication a(argc, argv);
00074 
00075     Plot plot;
00076 #if QT_VERSION < 0x040000
00077     a.setMainWidget(&plot);
00078 #endif
00079     plot.resize(600,400);
00080     plot.show();
00081     return a.exec(); 
00082 }
00083 */

Generated on Sun Aug 5 17:33:57 2007 for PIHMgis by  doxygen 1.5.2