Hello,

I would like to plot some kind of scatter graph on my QwtPlot to indicate feasible and infeasible regions on a spectrogramm, which is displayed on this QwtPlot, too. I have got some constraints or inequalities of type:
f(x1, x2) >= 0 , e.g. x2- x1^2 >=0 . Now, I have to calculate which coordinates of the plot violate the constraint and thus indicate it with a cross, for example. In forum, I have seen already that a scatter plot can be done by means of QwtPlotCurve, whereas one must set NOCURVE attribute to it:
Qt Code:
  1. _curve = new QwtPlotCurve();
  2.  
  3. _curve->setCurveStyle(QwtPlotCurve::NoCurve);
  4.  
  5.  
  6. QwtSymbol symbol;
  7.  
  8. symbol.setStyle(QwtSymbol::XCross);
  9.  
  10. symbol.setSize(QSize(6, 6));
  11.  
  12. _curve->setSymbol(symbol);
To copy to clipboard, switch view to plain text mode 

But how should I set the data to this curve then? If I use the example "SimplePlot" where a curve gets its data from SimpleData class, then it iterates only through x, but I need to iterate both through x1 and x2.
My idea was to write IF and ELSE conditions within constraint function, which returns 0 or 1 in regards to satisfying the constraint, thus I would get then a data array with 0 and 1 and could display it as scatter graph above the spectrogram plot.

Please give me a hint, which data container to use or generally how to manage my plan.

Thank you

Qt Code:
  1. class SimpleData: public QwtData
  2. {
  3. // The x values depend on its index and the y values
  4. // can be calculated from the corresponding x value.
  5. // So we don´t need to store the values.
  6. // Such an implementation is slower because every point
  7. // has to be recalculated for every replot, but it demonstrates how
  8. // QwtData can be used.
  9.  
  10. public:
  11. SimpleData(double(*y)(double), size_t size):
  12. d_size(size),
  13. d_y(y)
  14. {
  15. }
  16.  
  17. virtual QwtData *copy() const
  18. {
  19. return new SimpleData(d_y, d_size);
  20. }
  21.  
  22. virtual size_t size() const
  23. {
  24. return d_size;
  25. }
  26.  
  27. virtual double x(size_t i) const
  28. {
  29. return 0.1 * i;
  30. }
  31.  
  32. virtual double y(size_t i) const
  33. {
  34. return d_y(x(i));
  35. }
  36. private:
  37. size_t d_size;
  38. double(*d_y)(double);
  39. };
To copy to clipboard, switch view to plain text mode