void RasterSurfaceSeries::refresh(const Comn::Range<double>& range)
{
auto pixelHint
= p_data
->m_spectro
->pixelHint
(QRectF(0,
0,range.
end - range.
start,
p_data->m_yRange.end - p_data->m_yRange.start));
double dx = 0.001;
double dy = 0.001;
if (pixelHint.isValid())
{
dx = pixelHint.width();
dy = pixelHint.height();
}
double xPan = range.end - range.start;
double yPan = p_data->m_yRange.end - p_data->m_yRange.start;
int height = yPan / dy ;
int width = xPan / dx ;
QSize plotSize
(width,height
);
auto rasterData = p_data->m_spectro->data();
QSurfaceDataArray *dataArray = new QSurfaceDataArray;
dataArray->reserve(height);
for (int i = 0; i < height; i++) {
QSurfaceDataRow *newRow = new QSurfaceDataRow(width);
for (int j = 0; j < width; j++) {
float x = float(j) * dx + range.start;
float y = float(i) * dy + p_data->m_yRange.start;
float z = rasterData->value(x,y) + p_data->m_zOffset;
(*newRow)[j].setPosition(QVector3D(x, z,y));
}
*dataArray << newRow;
}
dataProxy()->resetArray(dataArray);
plotImage.
fill(QColor(Qt
::white));
xMap.setPaintInterval(0, plotSize.width());
xMap.setScaleInterval(range.start,range.end);
yMap.setPaintInterval(plotSize.height(), 0); // inverted !!!
yMap.setScaleInterval(p_data->m_yRange.start,p_data->m_yRange.end);
p_data
->m_spectro
->draw
(&painter, xMap, yMap,
QRect(QPoint(0,
0), plotSize
));
setTexture(plotImage);
}
void RasterSurfaceSeries::refresh(const Comn::Range<double>& range)
{
auto pixelHint = p_data->m_spectro->pixelHint(QRectF(0,0,range.end - range.start,
p_data->m_yRange.end - p_data->m_yRange.start));
double dx = 0.001;
double dy = 0.001;
if (pixelHint.isValid())
{
dx = pixelHint.width();
dy = pixelHint.height();
}
double xPan = range.end - range.start;
double yPan = p_data->m_yRange.end - p_data->m_yRange.start;
int height = yPan / dy ;
int width = xPan / dx ;
QSize plotSize (width,height);
auto rasterData = p_data->m_spectro->data();
QSurfaceDataArray *dataArray = new QSurfaceDataArray;
dataArray->reserve(height);
for (int i = 0; i < height; i++) {
QSurfaceDataRow *newRow = new QSurfaceDataRow(width);
for (int j = 0; j < width; j++) {
float x = float(j) * dx + range.start;
float y = float(i) * dy + p_data->m_yRange.start;
float z = rasterData->value(x,y) + p_data->m_zOffset;
(*newRow)[j].setPosition(QVector3D(x, z,y));
}
*dataArray << newRow;
}
dataProxy()->resetArray(dataArray);
QImage plotImage = QImage(plotSize,QImage::Format::Format_RGB32);
plotImage.fill(QColor(Qt::white));
QPainter painter(&plotImage);
QwtScaleMap xMap;
xMap.setPaintInterval(0, plotSize.width());
xMap.setScaleInterval(range.start,range.end);
QwtScaleMap yMap;
yMap.setPaintInterval(plotSize.height(), 0); // inverted !!!
yMap.setScaleInterval(p_data->m_yRange.start,p_data->m_yRange.end);
p_data->m_spectro->draw(&painter, xMap, yMap, QRect(QPoint(0, 0), plotSize));
setTexture(plotImage);
}
To copy to clipboard, switch view to plain text mode
Bookmarks