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:
QwtValueList contourLevels;
for ( double level = 0.5; level < 10.0; level += 1.0 )
contourLevels += level;
d_spectrogram->setContourLevels(contourLevels);
// A color bar on the right axis
rightAxis->setTitle("Intensity");
rightAxis->setColorBarEnabled(true);
rightAxis->setColorMap(d_spectrogram->data().range(), d_spectrogram->colorMap());
d_spectrogram->data().range().minValue(),
d_spectrogram->data().range().maxValue() );
QwtValueList contourLevels;
for ( double level = 0.5; level < 10.0; level += 1.0 )
contourLevels += level;
d_spectrogram->setContourLevels(contourLevels);
// A color bar on the right axis
QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight);
rightAxis->setTitle("Intensity");
rightAxis->setColorBarEnabled(true);
rightAxis->setColorMap(d_spectrogram->data().range(), d_spectrogram->colorMap());
setAxisScale(QwtPlot::yRight,
d_spectrogram->data().range().minValue(),
d_spectrogram->data().range().maxValue() );
enableAxis(QwtPlot::yRight);
To copy to clipboard, switch view to plain text mode
and my QwtData is:
typedef double (*benchFunc)(double, double); // definition of function pointer for benchmark function
{
public:
SpectrogramData(benchFunc b, double rang1[2], double rang2[2]):
QwtRasterData(QwtDoubleRect
(rang1
[0], rang2
[0], rang1
[1]- rang1
[0], rang2
[1]- rang2
[0])) {
MybenchFunc = b;
rangeX1[0] = rang1[0]; rangeX1[1] = rang1[1];
rangeX2[0] = rang1[0]; rangeX2[1] = rang2[1];
}
{
return new SpectrogramData(*this);
}
{
}
virtual double value(double x, double y) const
{
const double result = MybenchFunc(x,y);
return result;
}
private:
benchFunc MybenchFunc; // function pointer for benchmark function
double rangeX1[2];
double rangeX2[2];
};
typedef double (*benchFunc)(double, double); // definition of function pointer for benchmark function
class SpectrogramData: public QwtRasterData
{
public:
SpectrogramData(benchFunc b, double rang1[2], double rang2[2]):
QwtRasterData(QwtDoubleRect(rang1[0], rang2[0], rang1[1]- rang1[0], rang2[1]- rang2[0]))
{
MybenchFunc = b;
rangeX1[0] = rang1[0]; rangeX1[1] = rang1[1];
rangeX2[0] = rang1[0]; rangeX2[1] = rang2[1];
}
virtual QwtRasterData *copy() const
{
return new SpectrogramData(*this);
}
virtual QwtDoubleInterval range() const
{
return QwtDoubleInterval(-5.0, 5.0);
}
virtual double value(double x, double y) const
{
const double result = MybenchFunc(x,y);
return result;
}
private:
benchFunc MybenchFunc; // function pointer for benchmark function
double rangeX1[2];
double rangeX2[2];
};
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
Bookmarks