Hello every one, i am working on a plotting software where i have to plot some temperature data. I wrote the program but i am missing something i guess.. I don't have the temperature data plotted..
#include "mux_selection.h"
mux_selection
::mux_selection(QWidget *parent
) , m_curve(0)
, curve(0)
{
minX =0;
maxX =60;
//enable the x and y axis lines
grid->enableX(true);
grid->enableY(true);
timerdrawplot
= new QTimer(this);
//set the X and Y division and scale to that of the channels
grid
->setXDiv
(*(myPlot
->axisScaleDiv
(QwtPlot::xBottom)));
grid
->setYDiv
(*(myPlot
->axisScaleDiv
(QwtPlot::yLeft)));
grid->attach(myPlot);
myPlot->setCanvasBackground("lightyellow");
myPlot->setTitle("Data Receiver");
myPlot
->setAxisTitle
(QwtPlot::xBottom,
"Time in Seconds");
myPlot
->setAxisScale
(QwtPlot::xBottom,
0,
60);
myPlot
->setAxisTitle
(QwtPlot::yLeft,
"<FONT color=#0000ff face=Arial size=4><B> Temperature in C° </FONT>");
myPlot
->setAxisScale
(QwtPlot::yLeft,
-200,
+200);
myPlot->setAutoReplot(true);
}
#include "mux_selection.h"
mux_selection::mux_selection(QWidget *parent)
: QDialog(parent)
, m_curve(0)
, curve(0)
{
minX =0;
maxX =60;
QwtPlotGrid *grid = new QwtPlotGrid();
//enable the x and y axis lines
grid->enableX(true);
grid->enableY(true);
timerdrawplot = new QTimer(this);
//set the X and Y division and scale to that of the channels
grid->setXDiv(*(myPlot->axisScaleDiv(QwtPlot::xBottom)));
grid->setYDiv(*(myPlot->axisScaleDiv(QwtPlot::yLeft)));
grid->attach(myPlot);
myPlot->setCanvasBackground("lightyellow");
myPlot->setTitle("Data Receiver");
myPlot->setAxisTitle(QwtPlot::xBottom, "Time in Seconds");
myPlot->setAxisScale(QwtPlot::xBottom, 0, 60);
myPlot->setAxisTitle(QwtPlot::yLeft, "<FONT color=#0000ff face=Arial size=4><B> Temperature in C° </FONT>");
myPlot->setAxisScale(QwtPlot::yLeft, -200, +200);
myPlot->setAutoReplot(true);
}
To copy to clipboard, switch view to plain text mode
i am calling the plot function when i click the plot button using a timer every 1000 mili sec. right now i am retrieving one channel data from the db and trying to display it.
void mux_selection::plot()
{
m_vx.clear(); // QVector<double> m_vx,m_vy;
m_vy.clear();
QSqlQuery q
("select "+ colNames
+" from tempdata where rowid = " + QString::number(rowcnt
));
// colNames = channel1;
while(q.next())
{
m_vx.push_back(q.value(0).toDouble());
m_vy.push_back(q.value(1).toDouble());
}
if(m_vx.count()!= 0)
{
rowcnt++;
}
qDebug()<<m_vy<<m_vx<<rowcnt;
if (!m_curve)
{
m_curve
->setPen
(QPen(Qt
::black,
2,t
::SolidLine));
m_curve->setData(m_vx.data(), m_vy.data(), m_vx.count());
}
myPlot
->setAxisScale
( QwtPlot::xBottom, minX , maxX
);
myPlot->replot();
}
void mux_selection::plot()
{
m_vx.clear(); // QVector<double> m_vx,m_vy;
m_vy.clear();
QSqlQuery q("select "+ colNames +" from tempdata where rowid = " + QString::number(rowcnt)); // colNames = channel1;
while(q.next())
{
m_vx.push_back(q.value(0).toDouble());
m_vy.push_back(q.value(1).toDouble());
}
if(m_vx.count()!= 0)
{
rowcnt++;
}
qDebug()<<m_vy<<m_vx<<rowcnt;
if (!m_curve)
{
m_curve = new QwtPlotCurve();
m_curve->setPen(QPen(Qt::black, 2,t::SolidLine));
m_curve->setData(m_vx.data(), m_vy.data(), m_vx.count());
}
myPlot->setAxisScale( QwtPlot::xBottom, minX , maxX );
myPlot->replot();
}
To copy to clipboard, switch view to plain text mode
i am able to figure out where i am going wrong...
Thank you
Added after 1 55 minutes:
hello is there anything wrong in the program. . ? pls help me out not able to know where i am going wrong.
thanks so much
Bookmarks