swinetha
24th July 2013, 07:27
Hai,
I am newbie to QT as well as Qwt.
I am having QT 5.0.2, QT Creator 2.7.0 and Qwt 6.1.0.
My requirement is Plotting the graph for the data is continuous data in real time, this data is reding from background process.
According to my application, I am started the background process using QProcess that process is .exe file for C code. In this C code ther is a while(1) loop for reading Infinite data. In GUI I am able to read the data also.
Now I want to plot the graph for those values to find the deviation.
I have simple qwt code as below
float y[20], x[20];
int i;
for(i=0;i<20;i++)
{
x[i]=i;
y[i]=2*sin((x[i]));
}
QwtPlot *plot=new QwtPlot();
plot->setTitle( "Plot Demo" );
plot->setCanvasBackground( Qt::white );
//plot->setAxisScale( QwtPlot::yLeft, 0.0, 20.0);
// plot->setAxisScale(QwtPlot::xBottom, 0.0, 20.0);
plot->insertLegend( new QwtLegend() );
plot->setAxisTitle(QwtPlot::xBottom, "X Axis");
plot->setAxisTitle(QwtPlot::yLeft, "Y Axis");
QwtPlotGrid *grid = new QwtPlotGrid();
grid->attach( plot );
grid->setPen( Qt::gray, 0.0, Qt::DotLine );
QwtPlotCurve *curve = new QwtPlotCurve();
curve->setTitle( "Pixel Count" );
curve->setPen(QPen(Qt::blue, 3,Qt::SolidLine) ),
curve->setRenderHint( QwtPlotItem::RenderAntialiased, true);
QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,QBrush(Qt::yellow),QPen(Qt::red ,2),QSize(8,8));
curve->setSymbol(symbol );
QPolygonF points;
for(i=0;i<20;i++)
points<<QPointF(x[i],y[i]);//<<QPointF(x2,y2)<<QPointF(x3,y3)<<QPointF(x4,y4)<< QPointF(x5,y5);
curve->setSamples( points );
curve->attach(plot );
plot->replot();
plot->resize( 600, 400 );
plot->show();
and code for reading the background data
QByteArray b1;
QList<QByteArray> read_data;
b1= process->readAllStandardOutput();
read_data=b1.split('\n');
int i=0,n=read_data.count();
float y[100000];
for(i=0;i<n;i++)
{
QString result=read_data.at(i);
result.remove(0,10);
qDebug("%s",result.toLatin1().data());
y[i]=result.toLatin1().toFloat();
}
how can I send the data in y[i] to "QPolygonF points"
tried to send to QPolygonF but am not getting what I want.
any one can give suggetions to meet my requirment
Thanks in advance
I am newbie to QT as well as Qwt.
I am having QT 5.0.2, QT Creator 2.7.0 and Qwt 6.1.0.
My requirement is Plotting the graph for the data is continuous data in real time, this data is reding from background process.
According to my application, I am started the background process using QProcess that process is .exe file for C code. In this C code ther is a while(1) loop for reading Infinite data. In GUI I am able to read the data also.
Now I want to plot the graph for those values to find the deviation.
I have simple qwt code as below
float y[20], x[20];
int i;
for(i=0;i<20;i++)
{
x[i]=i;
y[i]=2*sin((x[i]));
}
QwtPlot *plot=new QwtPlot();
plot->setTitle( "Plot Demo" );
plot->setCanvasBackground( Qt::white );
//plot->setAxisScale( QwtPlot::yLeft, 0.0, 20.0);
// plot->setAxisScale(QwtPlot::xBottom, 0.0, 20.0);
plot->insertLegend( new QwtLegend() );
plot->setAxisTitle(QwtPlot::xBottom, "X Axis");
plot->setAxisTitle(QwtPlot::yLeft, "Y Axis");
QwtPlotGrid *grid = new QwtPlotGrid();
grid->attach( plot );
grid->setPen( Qt::gray, 0.0, Qt::DotLine );
QwtPlotCurve *curve = new QwtPlotCurve();
curve->setTitle( "Pixel Count" );
curve->setPen(QPen(Qt::blue, 3,Qt::SolidLine) ),
curve->setRenderHint( QwtPlotItem::RenderAntialiased, true);
QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,QBrush(Qt::yellow),QPen(Qt::red ,2),QSize(8,8));
curve->setSymbol(symbol );
QPolygonF points;
for(i=0;i<20;i++)
points<<QPointF(x[i],y[i]);//<<QPointF(x2,y2)<<QPointF(x3,y3)<<QPointF(x4,y4)<< QPointF(x5,y5);
curve->setSamples( points );
curve->attach(plot );
plot->replot();
plot->resize( 600, 400 );
plot->show();
and code for reading the background data
QByteArray b1;
QList<QByteArray> read_data;
b1= process->readAllStandardOutput();
read_data=b1.split('\n');
int i=0,n=read_data.count();
float y[100000];
for(i=0;i<n;i++)
{
QString result=read_data.at(i);
result.remove(0,10);
qDebug("%s",result.toLatin1().data());
y[i]=result.toLatin1().toFloat();
}
how can I send the data in y[i] to "QPolygonF points"
tried to send to QPolygonF but am not getting what I want.
any one can give suggetions to meet my requirment
Thanks in advance