Hi I am using qwtspectrogram to plot my array data but the problem i am having is scaling.. the qwt scales are distributed over the intervals x and y and the axis are dependent on the pixels. for example if I have a data set of (500×500) and i want to plot for 500mm x500mm its perfect because it is translated over the pixels but if i want to plot 500×500 number of points for 300mmx300mm it is a mess and it shows in the plot 500×500 i know i have to manage the x and y axis but I have no idea how to do that. I manage to play a little and display 500×500 for 250mmx250mm area but can not do for others.
my code is as shown below
{
char filepath[35];
QVector<qint16> fileBuf;
int pixel =500; // it represents the number of pixels in one row or column
int dial =1000;
public:
mydata()
{
setInterval( Qt::XAxis, QwtInterval( 0, (pixel)-1 ) );
setInterval( Qt::YAxis, QwtInterval( 0, (pixel)-1 ) );
setInterval( Qt::ZAxis, QwtInterval( -dial, dial ) );
{
sprintf_s(filepath, "c:\\myfile.bin");
myfile.setFileName(filepath);
if(!myfile.
open(QIODevice::ReadOnly)) return;
while(!data.atEnd()) {
qint16 x;
data >> x;
fileBuf.append(x);
}
myfile.close();
}
}
virtual double value( double x, double y ) const
{
int x_pos = static_cast<int>(x);
int y_pos = static_cast<int>(y);
double c = (fileBuf[ ((x_pos)+((pixel-(y_pos))*pixel))]);
return c;
}
}
class mydata: public QwtRasterData
{
char filepath[35];
QFile myfile;
QVector<qint16> fileBuf;
int pixel =500; // it represents the number of pixels in one row or column
int dial =1000;
public:
mydata()
{
setInterval( Qt::XAxis, QwtInterval( 0, (pixel)-1 ) );
setInterval( Qt::YAxis, QwtInterval( 0, (pixel)-1 ) );
setInterval( Qt::ZAxis, QwtInterval( -dial, dial ) );
{
sprintf_s(filepath, "c:\\myfile.bin");
myfile.setFileName(filepath);
if(!myfile.open(QIODevice::ReadOnly)) return;
QDataStream data(&myfile);
data.setByteOrder(QDataStream::LittleEndian);
while(!data.atEnd()) {
qint16 x;
data >> x;
fileBuf.append(x);
}
myfile.close();
}
}
virtual double value( double x, double y ) const
{
int x_pos = static_cast<int>(x);
int y_pos = static_cast<int>(y);
double c = (fileBuf[ ((x_pos)+((pixel-(y_pos))*pixel))]);
return c;
}
}
To copy to clipboard, switch view to plain text mode
in short i have same number of pixels for different areas but i have same representation of axis in plot.
Bookmarks