#include "preview.h"
#include <QFile>
{
public:
{
addColorStop(0.05, Qt::blue);
addColorStop(0.3, Qt::cyan);
addColorStop(0.7, Qt::yellow);
addColorStop(0.9, Qt::red);
addColorStop(1, Qt::darkRed);
}
};
class previewMatrixData : public QwtMatrixRasterData
{
public:
previewMatrixData(const QVector<double> &pressureVector, int Nx, int Ny, float dx, float dy, float pd)
{
setValueMatrix(pressureVector, Ny+2);
setInterval(Qt::YAxis, QwtInterval(0, Ny+2));
setInterval(Qt::XAxis, QwtInterval(0, Nx+2));
setInterval(Qt::ZAxis, QwtInterval(0, pd));
setResampleMode(BilinearInterpolation);
}
};
{
this->setAttribute(Qt::WA_DeleteOnClose, true);
previewSpectogram->attach(previewPlot);
previewPlotLayout->setAlignment(Qt::AlignCenter);
previewPlotLayout->addWidget(previewPlot);
// canvasBackground = new QBrush(Qt::white, Qt::SolidPattern);
previewPlot
->setCanvasBackground
(QBrush(Qt
::white, Qt
::SolidPattern));
previewPlot->setCanvasLineWidth(0);
previewPlot->enableAxis(0, true);
previewPlot->enableAxis(2, false);
previewPlot->enableAxis(3, true);
previewPlot->plotLayout()->setAlignCanvasToScales(true);
previewPlot->setAxisScale(0, 10, 0);
previewPlot->setAxisScale(3, 0, 10);
previewPlot->axisWidget(0)->setMargin(10);
previewPlot->axisWidget(3)->setMargin(10);
this->setLayout(previewPlotLayout);
}
void preview
::constructOrificePreview(QTableWidget *orificePos
) {
///////ALGORITHM HERE EXTRACTED FROM CODE
qDebug() << rasterMatrix.size();
qDebug() << rasterMatrix.count();
qDebug() << "Nx " << Nx << "Ny " << Ny;
(Debug_output =
10404, 10404, 100, 100 )
previewSpectogram->setColorMap(new previewColorMap(pa, pd));
previewSpectogram->setData(new previewMatrixData(rasterMatrix, Nx, Ny, dx, dy, pd));
previewPlot
->axisWidget
(QwtPlot::yRight)->setTitle
(tr
("Intensität"));
previewPlot
->axisWidget
(QwtPlot::yRight)->setColorBarEnabled
(true);
previewPlot
->axisWidget
(QwtPlot::yRight)->setColorMap
(QwtInterval
(pa
/1e6, pd
/1e6
),
new previewColorMap
(pa
/1e6,pd
/1e6
));
previewPlot
->setAxisScale
(QwtPlot::yRight, pa
/1e6, pd
/1e6
);
previewPlot->enableAxis(1, true);
previewPlot
->setAxisScale
(QwtPlot::xTop,
0.0 , x
*1e3
);
previewPlot
->setAxisMaxMinor
(QwtPlot::xTop,
5);
previewPlot
->setAxisScale
(QwtPlot::yLeft, y
*1e3,
0.0);
previewPlot
->setAxisMaxMinor
(QwtPlot::yLeft,
5);
previewPlot->replot();
}
#include "preview.h"
#include <QFile>
class previewColorMap : public QwtLinearColorMap
{
public:
previewColorMap(float pa, float pd) : QwtLinearColorMap(Qt::blue, Qt::darkRed)
{
addColorStop(0.05, Qt::blue);
addColorStop(0.3, Qt::cyan);
addColorStop(0.7, Qt::yellow);
addColorStop(0.9, Qt::red);
addColorStop(1, Qt::darkRed);
}
};
class previewMatrixData : public QwtMatrixRasterData
{
public:
previewMatrixData(const QVector<double> &pressureVector, int Nx, int Ny, float dx, float dy, float pd)
{
setValueMatrix(pressureVector, Ny+2);
setInterval(Qt::YAxis, QwtInterval(0, Ny+2));
setInterval(Qt::XAxis, QwtInterval(0, Nx+2));
setInterval(Qt::ZAxis, QwtInterval(0, pd));
setResampleMode(BilinearInterpolation);
}
};
preview::preview(QWidget *parent) : QWidget(parent)
{
this->setAttribute(Qt::WA_DeleteOnClose, true);
previewPlot = new QwtPlot;
previewSpectogram = new QwtPlotSpectrogram;
previewSpectogram->attach(previewPlot);
previewPlotLayout = new QVBoxLayout;
previewPlotLayout->setAlignment(Qt::AlignCenter);
previewPlotLayout->addWidget(previewPlot);
// canvasBackground = new QBrush(Qt::white, Qt::SolidPattern);
previewPlot->setCanvasBackground(QBrush(Qt::white, Qt::SolidPattern));
previewPlot->setCanvasLineWidth(0);
previewPlot->enableAxis(0, true);
previewPlot->enableAxis(2, false);
previewPlot->enableAxis(3, true);
previewPlot->plotLayout()->setAlignCanvasToScales(true);
previewPlot->setAxisScale(0, 10, 0);
previewPlot->setAxisScale(3, 0, 10);
previewPlot->axisWidget(0)->setMargin(10);
previewPlot->axisWidget(3)->setMargin(10);
this->setLayout(previewPlotLayout);
}
void preview::constructOrificePreview(QTableWidget *orificePos)
{
///////ALGORITHM HERE EXTRACTED FROM CODE
qDebug() << rasterMatrix.size();
qDebug() << rasterMatrix.count();
qDebug() << "Nx " << Nx << "Ny " << Ny;
(Debug_output =
10404, 10404, 100, 100 )
previewSpectogram->setColorMap(new previewColorMap(pa, pd));
previewSpectogram->setData(new previewMatrixData(rasterMatrix, Nx, Ny, dx, dy, pd));
previewPlot->axisWidget(QwtPlot::yRight)->setTitle(tr("Intensität"));
previewPlot->axisWidget(QwtPlot::yRight)->setColorBarEnabled(true);
previewPlot->axisWidget(QwtPlot::yRight)->setColorMap(QwtInterval(pa/1e6, pd/1e6), new previewColorMap(pa/1e6,pd/1e6));
previewPlot->setAxisScale(QwtPlot::yRight, pa/1e6, pd/1e6);
previewPlot->enableAxis(1, true);
previewPlot->setAxisScale(QwtPlot::xTop, 0.0 , x*1e3);
previewPlot->setAxisMaxMinor(QwtPlot::xTop, 5);
previewPlot->setAxisScale(QwtPlot::yLeft, y*1e3, 0.0);
previewPlot->setAxisMaxMinor(QwtPlot::yLeft, 5);
previewPlot->replot();
}
To copy to clipboard, switch view to plain text mode
Bookmarks