Re: Q3DSurface and contouring
Hello,
I am Q3DSurface to display my 3D data in my desktop app. I want to add more into the 3D plot like the following
- Contour lines given contour levels
- multiple markers placed in an XYZ location
Can someone give me some hints or share some experience about these items?
Any idea will be appreciated,
baray98
Added after 10 minutes:
Quote:
Originally Posted by
baray98
Hello,
I am Q3DSurface to display my 3D data in my desktop app. I want to add more into the 3D plot like the following
- Contour lines given contour levels
- multiple markers placed in an XYZ location
Can someone give me some hints or share some experience about these items?
Any idea will be appreciated,
baray98
P.S. I can even abandon Qt 3D Visualization if I can find a good 3D plot library that can suffice my reqs
Re: Q3DSurface and contouring
Quote:
I can even abandon Qt 3D Visualization if I can find a good 3D plot library that can suffice my reqs
If you find one, post the link. I've been looking for years with no luck. The Qt folks really screwed up with the Qt Charts and Qt Data Visualization frameworks by making it impossible to extend them in any way. Not a virtual method to be found anywhere. You get what they give you and that's it.
Other frameworks like VTK are as huge as Qt.
Re: Q3DSurface and contouring
Trying VTK and update this thread soon
Re: Q3DSurface and contouring
Quote:
Trying VTK and update this thread soon
I've done a few small things with VTK, but the learning curve is really tough, and aside from being able to host a VTK window in a QWidget, there isn't much integration with other Qt data structures. Good luck.
Re: Q3DSurface and contouring
Took me 2 days to figure out how to host vtkContextView in QVTKOpenGLStereoWidge. I have a surface plot on it but it looks primitive. Not a whole lot of tutorial out there. Are there any good looking ones like (Q3DSurface ) out there that I could try? Suggestions are welcome.
1 Attachment(s)
Re: Q3DSurface and contouring
I actually managed to do contouring with Q3dSurface by combining QwtPlotSpectrogram;
see pitureAttachment 13593
IDEA:
- Initialize Q3DSurfaceSeries with QwtRaster from QwtPlotSpectogram to get Z values;
- Get QwtPlotSpectogram draw the image into QImage QwtPlotSpectogram ::draw();
- Use image as texture of Q3dSurfaceSeries Q3dSurfaceSeries::setTexture(QImage);
- So contouring is just a matter of setting spectogram to turn it on or off;
- That should do it .. play with resolution along x and y for satisfaction.
Code:
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);
}