Hello everybody!
My name is Chris, I´m new here and would like to express my greatest gratitude to however can help me out as I´m stuck on something I´m not really good at.
My problem: I just started using Qwt since 1 week.
My specific problem:
I have absolute values of a digital process stored in: extern long Abs[1024][256];
I have 1024 values I want to plot on the X-Axis and 256 values on the Y-Axis, using the Spectrogram but I want them not to be scaled 0-1023 and 0-255 but with FREQUENCY and TIME, so
X-AXIS: 0 to 2048us with step 2us
Y-AXIS: -2560 to 2560Hz with step 20Hz
In the GUI, the tab called Visualization is where I see my plot:
...
d_spectrogram->setRenderThreadCount( 0 ); // use system specific thread count
d_spectrogram->setColorMap( new ColorMap() );
d_spectrogram->setData(new DSPFunc() );
d_spectrogram->attach(ui->tab_Visualization->ui->qwtPlot_dataView);
ui->tab_Visualization->ui->qwtPlot_dataView->replot();
...
...
d_spectrogram = new QwtPlotSpectrogram();
d_spectrogram->setRenderThreadCount( 0 ); // use system specific thread count
d_spectrogram->setColorMap( new ColorMap() );
d_spectrogram->setCachePolicy( QwtPlotRasterItem::PaintCache );
d_spectrogram->setData(new DSPFunc() );
d_spectrogram->attach(ui->tab_Visualization->ui->qwtPlot_dataView);
ui->tab_Visualization->ui->qwtPlot_dataView->replot();
...
To copy to clipboard, switch view to plain text mode
Here is the header of the function:
{
public:
DSPFunc();
virtual double value( double x, double y ) const;
};
#endif // DSPFUNC_H
class DSPFunc : public QwtRasterData
{
public:
DSPFunc();
virtual double value( double x, double y ) const;
};
#endif // DSPFUNC_H
To copy to clipboard, switch view to plain text mode
Here is the code
DSPFunc::DSPFunc()
{
setInterval( Qt::XAxis, QwtInterval( 0.0, 1024.0 ) );
setInterval( Qt::YAxis, QwtInterval( 0.0, 256.0 ) );
setInterval( Qt::ZAxis, QwtInterval( 0.0, 10.0 ) );
}
double DSPFunc::value( double x, double y ) const
{
if ((y >= 0.0) && (y <= double(256)) && (x >= 0.0) && (x <= double(1024)))
return Abs[quint16(floor(x))][quint16(floor(y))];
else
return 0.0;
}
DSPFunc::DSPFunc()
{
setInterval( Qt::XAxis, QwtInterval( 0.0, 1024.0 ) );
setInterval( Qt::YAxis, QwtInterval( 0.0, 256.0 ) );
setInterval( Qt::ZAxis, QwtInterval( 0.0, 10.0 ) );
}
double DSPFunc::value( double x, double y ) const
{
if ((y >= 0.0) && (y <= double(256)) && (x >= 0.0) && (x <= double(1024)))
return Abs[quint16(floor(x))][quint16(floor(y))];
else
return 0.0;
}
To copy to clipboard, switch view to plain text mode
Here is the visualization part:
Visualization
::Visualization(QWidget *parent
) : ui(new Ui::Visualization)
{
ui->setupUi(this);
ui
->qwtPlot_dataView
->setAxisTitle
(QwtPlot::yLeft,
QwtText("FREQUENCY [Hz]"));
ui
->qwtPlot_dataView
->setAxisScale
(QwtPlot::yLeft,
-2560,
2560);
ui
->qwtPlot_dataView
->setAxisTitle
(QwtPlot::xBottom,
QwtText("TIME [µs]"));
ui
->qwtPlot_dataView
->setAxisScale
(QwtPlot::xBottom,
0,
2048 );
}
Visualization::~Visualization()
{
delete ui;
}
Visualization::Visualization(QWidget *parent) :
QDialog(parent),
ui(new Ui::Visualization)
{
ui->setupUi(this);
ui->qwtPlot_dataView->setAxisTitle(QwtPlot::yLeft, QwtText("FREQUENCY [Hz]"));
ui->qwtPlot_dataView->setAxisScale(QwtPlot::yLeft, -2560, 2560);
ui->qwtPlot_dataView->setAxisTitle(QwtPlot::xBottom, QwtText("TIME [µs]"));
ui->qwtPlot_dataView->setAxisScale(QwtPlot::xBottom, 0, 2048 );
}
Visualization::~Visualization()
{
delete ui;
}
To copy to clipboard, switch view to plain text mode
Right now I see a plot that has the correct axis but data is not scaled correcty. I would like to know If I need to operate my changes on the
values returned here:
return Abs[quint16(floor(x))][quint16(floor(y))];
and if so how would I need to proceed.
Thanks and sorry for this simple and probably stupid question but Qwt is still a bit difficult for me and I really need help.
Bookmarks