I want to draw a spectrogram with size 2000*2000. However, i don't want the axis scale numbers to be from 0 to 2000, but rather a linear transformation, where 2000 is mapped to a certain number (e.g. 120), and the rest of the values are mapped accordingly.

I declare a
Qt Code:
  1. QwtPlotSpectrogram * spectrogram
To copy to clipboard, switch view to plain text mode 

instance, and i use setData() function to pass a SpectrogramData instance:
Qt Code:
  1. class SpectrogramData : public QwtMatrixRasterData, public QwtLinearScaleEngine {
  2. private:
  3. std::vector<std::vector<double>> data_;
  4. public:
  5. SpectrogramData();
  6. ~SpectrogramData();
  7. void setData(std::vector<std::vector<double>> & data) { data_ = data; }
  8. virtual double value(double x, double y) const{ return data_[x][y]; }
  9. };
To copy to clipboard, switch view to plain text mode 

Then i initialize the QwtPlot:
Qt Code:
  1. plot_ = new QwtPlot(this);
  2. ...
  3. spectrogram_ = new QwtPlotSpectrogram();
  4. spectrogram_data_ = new SpectrogramData();
  5. ...
  6. spectrogram_->setData(spectrogram_data_);
  7. spectrogram_->attach(plot_);
To copy to clipboard, switch view to plain text mode 


The problem is that when i draw something, i have to use setInterval() on the spectrogram_data object, but the values 0 and 2000, for min and max, that i pass in order to fully draw the 2000*2000 matrix, set the axis to 0-2000 as well. If i give smaller values to setInterval() then part of the matrix is not drawn.

What i tried is to use QwtTranform, since i want a linear transformation, but as i am given to understand, it does not behave the way i want:
Qt Code:
  1. class AxisTransformation : public QwtTransform {
  2. private:
  3. double prev_start_, prev_end_;
  4. double new_start_, new_end_;
  5. public:
  6. AxisTransformation(double prev_start, double prev_end, double new_start, double new_end) : prev_start_(prev_start), prev_end_(prev_end), new_start_(new_start), new_end_(new_end) {}
  7. virtual double transform(double value) const {
  8. return new_value = new_start_ + (new_end_ - new_start_) * (value - prev_start_) / (prev_end_ - prev_start_);
  9. }
  10. virtual double invTransform(double value) const {
  11. return new_value = prev_start_ + (prev_end_ - prev_start_) * (value - new_start_) / (new_end_ - new_start_);
  12. }
  13. AxisTransformation * copy() const {
  14. return new AxisTransformation(*this);
  15. }
  16. };
To copy to clipboard, switch view to plain text mode 
along with
Qt Code:
  1. AxisTransformation * t = new AxisTransformation(0, 2000, 0, 120);
  2. QwtScaleWidget * axis_x_bottom = plot_->axisWidget(QwtPlot::xBottom);
  3. axis_x_bottom->setTransformation(t);
To copy to clipboard, switch view to plain text mode 

So how can i fully draw the 2000*2000 matrix, but specifying the axis numbers displayed to be from 0 to 120?