comparison examples/qwt/simpleplot/simple.d @ 383:bd7f485e3573

More debug fixes
author Max Samukha <maxter@spambox.com>
date Mon, 12 Jul 2010 22:50:58 +0300
parents 347e4c7a9ba1
children
comparison
equal deleted inserted replaced
382:1d56b2a2e10c 383:bd7f485e3573
30 alias real function(real) double_func; 30 alias real function(real) double_func;
31 31
32 class SimpleData: QwtData 32 class SimpleData: QwtData
33 { 33 {
34 // The x values depend on its index and the y values 34 // The x values depend on its index and the y values
35 // can be calculated from the corresponding x value. 35 // can be calculated from the corresponding x value.
36 // So we don't need to store the values. 36 // So we don't need to store the values.
37 // Such an implementation is slower because every point 37 // Such an implementation is slower because every point
38 // has to be recalculated for every replot, but it demonstrates how 38 // has to be recalculated for every replot, but it demonstrates how
39 // QwtData can be used. 39 // QwtData can be used.
40 40
41 public: 41 public:
42 this(const double_func y, size_t size) 42 this(const double_func y, size_t size)
78 insertLegend(new QwtLegend(), QwtPlot.RightLegend); 78 insertLegend(new QwtLegend(), QwtPlot.RightLegend);
79 79
80 // Set axis titles 80 // Set axis titles
81 setAxisTitle(xBottom, "x -->"); 81 setAxisTitle(xBottom, "x -->");
82 setAxisTitle(yLeft, "y -->"); 82 setAxisTitle(yLeft, "y -->");
83 83
84 // Insert new curves 84 // Insert new curves
85 auto cSin = new QwtPlotCurve("y = sin(x)"); 85 auto cSin = new QwtPlotCurve("y = sin(x)");
86 cSin.setRenderHint(QwtPlotItem.RenderAntialiased); 86 cSin.setRenderHint(QwtPlotItem.RenderAntialiased);
87 cSin.setPen(new QPen(new QColor(Qt.red))); 87 cSin.setPen(new QPen(new QColor(Qt.red)));
88 cSin.attach(this); 88 cSin.attach(this);
96 const int nPoints = 100; 96 const int nPoints = 100;
97 cSin.setData(new SimpleData(&mysin, nPoints)); 97 cSin.setData(new SimpleData(&mysin, nPoints));
98 cCos.setData(new SimpleData(&mycos, nPoints)); 98 cCos.setData(new SimpleData(&mycos, nPoints));
99 99
100 // Insert markers 100 // Insert markers
101 101
102 // ...a horizontal line at y = 0... 102 // ...a horizontal line at y = 0...
103 auto mY = new QwtPlotMarker(); 103 auto mY = new QwtPlotMarker();
104 mY.setLabel(new QwtText("y = 0")); 104 mY.setLabel(new QwtText("y = 0"));
105 mY.setLabelAlignment(Qt.AlignRight | Qt.AlignTop); 105 mY.setLabelAlignment(Qt.AlignRight | Qt.AlignTop);
106 mY.setLineStyle(QwtPlotMarker.HLine); 106 mY.setLineStyle(QwtPlotMarker.HLine);
125 auto a = new QApplication(args); 125 auto a = new QApplication(args);
126 126
127 scope plot = new Plot; 127 scope plot = new Plot;
128 plot.resize(600,400); 128 plot.resize(600,400);
129 plot.show(); 129 plot.show();
130 return a.exec(); 130 return a.exec();
131 } 131 }