分类: IT业界
2012-04-11 14:26:56
using namespace Qwt3D;
double** allocateData(int columns, int rows)
{
double** data = new double* [columns] ;
for ( int i = 0; i < columns; ++i)
{ data[i] = new double [rows]; }
return data;
}
void deleteData(double**data, int columns)
{
for ( int i = 0; i < columns; i++)
{ delete [] data[i]; }
delete [] data;
}
class Plot : public SurfacePlot
{
public: Plot();
};
Plot::Plot()
{
int i,j;
double x, y, z;
double** data = allocateData(100, 100);
for(i = 0; i< 100; i++)
{
for(j = 0; j< 100;j++)
{
x = (i - 50) / 5.0;
y = (j - 50) / 5.0;
z = hypot(x, y);
data[i][j] = cos(z);
}
}
loadFromData (data, 100, 100, -10, 10, -10, 10);
deleteData(data, 100);
setScale(1,1,5);
setCoordinateStyle(BOX);
updateData();
updateGL();
}
int main(int argc, char **argv)
{
QApplication a(argc, argv);
Plot plot;
plot.resize(800,600);
plot.show();
return a.exec();
}