Hello,

I would like to adapt the colormap in regard to the max and min values of intensity ( in a spectrogram). How can it be done?

here the colormap is set:

Qt Code:
  1. QwtValueList contourLevels;
  2. for ( double level = 0.5; level < 10.0; level += 1.0 )
  3. contourLevels += level;
  4. d_spectrogram->setContourLevels(contourLevels);
  5.  
  6. // A color bar on the right axis
  7. QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight);
  8. rightAxis->setTitle("Intensity");
  9. rightAxis->setColorBarEnabled(true);
  10. rightAxis->setColorMap(d_spectrogram->data().range(), d_spectrogram->colorMap());
  11.  
  12. setAxisScale(QwtPlot::yRight,
  13. d_spectrogram->data().range().minValue(),
  14. d_spectrogram->data().range().maxValue() );
  15. enableAxis(QwtPlot::yRight);
To copy to clipboard, switch view to plain text mode 

and my QwtData is:

Qt Code:
  1. typedef double (*benchFunc)(double, double); // definition of function pointer for benchmark function
  2.  
  3. class SpectrogramData: public QwtRasterData
  4. {
  5. public:
  6. SpectrogramData(benchFunc b, double rang1[2], double rang2[2]):
  7. QwtRasterData(QwtDoubleRect(rang1[0], rang2[0], rang1[1]- rang1[0], rang2[1]- rang2[0]))
  8. {
  9. MybenchFunc = b;
  10. rangeX1[0] = rang1[0]; rangeX1[1] = rang1[1];
  11. rangeX2[0] = rang1[0]; rangeX2[1] = rang2[1];
  12. }
  13.  
  14. virtual QwtRasterData *copy() const
  15. {
  16. return new SpectrogramData(*this);
  17. }
  18.  
  19. virtual QwtDoubleInterval range() const
  20. {
  21. return QwtDoubleInterval(-5.0, 5.0);
  22. }
  23.  
  24. virtual double value(double x, double y) const
  25. {
  26.  
  27. const double result = MybenchFunc(x,y);
  28. return result;
  29. }
  30.  
  31. private:
  32.  
  33. benchFunc MybenchFunc; // function pointer for benchmark function
  34. double rangeX1[2];
  35. double rangeX2[2];
  36. };
To copy to clipboard, switch view to plain text mode 

At the moment the range is set to (-5, 5), but it is fix. I want to make it dynamical.

Thanks for help.

best regards,

Vitali