1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
//-----------------------------------------------------------------
// simpleplot.cpp
//
// A simple example which shows how to use SurfacePlot
//-----------------------------------------------------------------
#include <math.h>
#include <qapplication.h>
#include <qwt3d_surfaceplot.h>
#include <qwt3d_function.h>
using namespace Qwt3D;
class Rosenbrock : public Function
{
public:
Rosenbrock(SurfacePlot& pw)
:Function(pw)
{
}
double operator()(double x, double y)
{
return log((1-x)*(1-x) + 100 * (y - x*x)*(y - x*x)) / 8;
}
};
class Plot : public SurfacePlot
{
public:
Plot();
};
Plot::Plot()
{
setTitle("A Simple SurfacePlot Demonstration");
Rosenbrock rosenbrock(*this);
rosenbrock.setMesh(41,31);
rosenbrock.setDomain(-1.73,1.5,-1.5,1.5);
rosenbrock.setMinZ(-10);
rosenbrock.create();
setRotation(30,0,15);
setScale(1,1,1);
setShift(0.15,0,0);
setZoom(0.9);
for (unsigned i=0; i!=coordinates()->axes.size(); ++i)
{
coordinates()->axes[i].setMajors(7);
coordinates()->axes[i].setMinors(4);
}
coordinates()->axes[X1].setLabelString("x-axis");
coordinates()->axes[Y1].setLabelString("y-axis");
//coordinates()->axes[Z1].setLabelString(QChar(0x38f)); // Omega - see http://www.unicode.org/charts/
setCoordinateStyle(BOX);
updateData();
updateGL();
}
int main(int argc, char **argv)
{
QApplication a(argc, argv);
Plot plot;
#if QT_VERSION < 0x040000
a.setMainWidget(&plot);
#endif
plot.resize(800,600);
plot.show();
return a.exec();
}
|