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 #include <QPainter>
00026 #include <QPoint>
00027
00028 #include <qwt_plot_curve.h>
00029 #include <qwt_plot_grid.h>
00030 #include <qwt_plot_layout.h>
00031 #include <qwt_plot_marker.h>
00032 #include <qwt_text.h>
00033
00034 #include "detailplot.h"
00035
00036 DetailPlot::DetailPlot(int linesize, QPointF lineAxis, QWidget *parent):
00037 QwtPlot(parent)
00038 {
00039 d_valid = false;
00040 samplesprCruve = linesize;
00041 setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
00042 d_lineAxisbounds = lineAxis;
00043 }
00044
00045 void DetailPlot::setData(const double *x, const double *y,
00046 const QString &dateTimeLabel)
00047 {
00048 if (!d_valid)
00049 {
00050
00051 d_curve = new QwtPlotCurve("Channel ...");
00052 d_curve->setPen(QPen(Qt::black));
00053 d_curve->setStyle(QwtPlotCurve::Lines);
00054 d_curve->attach(this);
00055
00056
00057 setAxisScale(QwtPlot::xBottom, 0.0, 10.0, 0.2);
00058 setAxisScale(QwtPlot::yLeft,
00059 d_lineAxisbounds.x(),
00060 d_lineAxisbounds.y(),
00061 qAbs((d_lineAxisbounds.y() - d_lineAxisbounds.x())) / 8);
00062
00063 setAxisMaxMinor(QwtPlot::xBottom, 5);
00064 setAxisMaxMinor(QwtPlot::yLeft, 5);
00065
00066
00067 QwtPlotGrid *grid = new QwtPlotGrid;
00068 grid->enableXMin(true);
00069 grid->enableYMin(true);
00070 grid->setMajPen(QPen(Qt::red, 0, Qt::SolidLine));
00071 grid->setMinPen(QPen(Qt::red, 0, Qt::DotLine));
00072 grid->attach(this);
00073
00074 d_valid = true;
00075 enableAxis(QwtPlot::yLeft, false);
00076 enableAxis(QwtPlot::xBottom, false);
00077 plotLayout()->setCanvasMargin(0);
00078
00079
00080 d_marker = new QwtPlotMarker;
00081 d_marker->setValue(0, d_lineAxisbounds.x());
00082 d_marker->setLineStyle(QwtPlotMarker::HLine);
00083 d_marker->setLabelAlignment(Qt::AlignLeft | Qt::AlignTop);
00084 d_marker->attach(this);
00085 }
00086 QwtText text(dateTimeLabel);
00087 text.setFont(QFont("Helvetica", 14, QFont::Bold));
00088 d_marker->setLabel(text);
00089 d_curve->setRawData(x, y, samplesprCruve);
00090 replot();
00091 updateGeometry();
00092 }