Hi Community,

I have the following problem:

I want to display a preview of an AirBearing_pressureDistribution in a SpectogramPlot.

Now what I get is a Spectogram:



Now the xTop und yLeft scales are scaled to the Matrix ( or to the number of elements that are in the MatrixVector here 102x102)

-> Why doesn't he go to 102 on the xTop scale, when I have 102x102 elements?

What I want is this picture, but scaled to the Bearing length and width. What I get is this:



How can I rescale the Plot, so he shows the first image in the length/width-rescaled plot.

Here the code:


Qt Code:
  1. #include "preview.h"
  2. #include <QFile>
  3.  
  4. class previewColorMap : public QwtLinearColorMap
  5. {
  6. public:
  7. previewColorMap(float pa, float pd) : QwtLinearColorMap(Qt::blue, Qt::darkRed)
  8. {
  9. addColorStop(0.05, Qt::blue);
  10. addColorStop(0.3, Qt::cyan);
  11. addColorStop(0.7, Qt::yellow);
  12. addColorStop(0.9, Qt::red);
  13. addColorStop(1, Qt::darkRed);
  14. }
  15. };
  16.  
  17. class previewMatrixData : public QwtMatrixRasterData
  18. {
  19. public:
  20. previewMatrixData(const QVector<double> &pressureVector, int Nx, int Ny, float dx, float dy, float pd)
  21. {
  22. setValueMatrix(pressureVector, Ny+2);
  23. setInterval(Qt::YAxis, QwtInterval(0, Ny+2));
  24. setInterval(Qt::XAxis, QwtInterval(0, Nx+2));
  25. setInterval(Qt::ZAxis, QwtInterval(0, pd));
  26. setResampleMode(BilinearInterpolation);
  27. }
  28. };
  29.  
  30. preview::preview(QWidget *parent) : QWidget(parent)
  31. {
  32. this->setAttribute(Qt::WA_DeleteOnClose, true);
  33.  
  34. previewPlot = new QwtPlot;
  35. previewSpectogram = new QwtPlotSpectrogram;
  36. previewSpectogram->attach(previewPlot);
  37. previewPlotLayout = new QVBoxLayout;
  38. previewPlotLayout->setAlignment(Qt::AlignCenter);
  39. previewPlotLayout->addWidget(previewPlot);
  40.  
  41.  
  42. // canvasBackground = new QBrush(Qt::white, Qt::SolidPattern);
  43. previewPlot->setCanvasBackground(QBrush(Qt::white, Qt::SolidPattern));
  44. previewPlot->setCanvasLineWidth(0);
  45. previewPlot->enableAxis(0, true);
  46. previewPlot->enableAxis(2, false);
  47. previewPlot->enableAxis(3, true);
  48. previewPlot->plotLayout()->setAlignCanvasToScales(true);
  49. previewPlot->setAxisScale(0, 10, 0);
  50. previewPlot->setAxisScale(3, 0, 10);
  51. previewPlot->axisWidget(0)->setMargin(10);
  52. previewPlot->axisWidget(3)->setMargin(10);
  53.  
  54. this->setLayout(previewPlotLayout);
  55. }
  56.  
  57. void preview::constructOrificePreview(QTableWidget *orificePos)
  58. {
  59.  
  60. ///////ALGORITHM HERE EXTRACTED FROM CODE
  61.  
  62.  
  63. qDebug() << rasterMatrix.size();
  64. qDebug() << rasterMatrix.count();
  65. qDebug() << "Nx " << Nx << "Ny " << Ny;
  66.  
  67. (Debug_output =
  68. 10404, 10404, 100, 100 )
  69.  
  70.  
  71. previewSpectogram->setColorMap(new previewColorMap(pa, pd));
  72. previewSpectogram->setData(new previewMatrixData(rasterMatrix, Nx, Ny, dx, dy, pd));
  73. previewPlot->axisWidget(QwtPlot::yRight)->setTitle(tr("Intensität"));
  74. previewPlot->axisWidget(QwtPlot::yRight)->setColorBarEnabled(true);
  75. previewPlot->axisWidget(QwtPlot::yRight)->setColorMap(QwtInterval(pa/1e6, pd/1e6), new previewColorMap(pa/1e6,pd/1e6));
  76. previewPlot->setAxisScale(QwtPlot::yRight, pa/1e6, pd/1e6);
  77. previewPlot->enableAxis(1, true);
  78.  
  79. previewPlot->setAxisScale(QwtPlot::xTop, 0.0 , x*1e3);
  80. previewPlot->setAxisMaxMinor(QwtPlot::xTop, 5);
  81. previewPlot->setAxisScale(QwtPlot::yLeft, y*1e3, 0.0);
  82. previewPlot->setAxisMaxMinor(QwtPlot::yLeft, 5);
  83.  
  84. previewPlot->replot();
  85. }
To copy to clipboard, switch view to plain text mode