Results 1 to 6 of 6

Thread: Q3DSurface and contouring

  1. #1
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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 View Post
    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
    Last edited by baray98; 28th January 2021 at 00:37.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Q3DSurface and contouring

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Q3DSurface and contouring

    Trying VTK and update this thread soon

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Q3DSurface and contouring

    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.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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.

  6. #6
    Join Date
    Aug 2007
    Posts
    275
    Thanks
    28
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Q3DSurface and contouring

    I actually managed to do contouring with Q3dSurface by combining QwtPlotSpectrogram;

    see piturezoom.jpg

    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.


    Qt Code:
    1. void RasterSurfaceSeries::refresh(const Comn::Range<double>& range)
    2. {
    3.  
    4. auto pixelHint = p_data->m_spectro->pixelHint(QRectF(0,0,range.end - range.start,
    5. p_data->m_yRange.end - p_data->m_yRange.start));
    6. double dx = 0.001;
    7. double dy = 0.001;
    8. if (pixelHint.isValid())
    9. {
    10. dx = pixelHint.width();
    11. dy = pixelHint.height();
    12. }
    13. double xPan = range.end - range.start;
    14. double yPan = p_data->m_yRange.end - p_data->m_yRange.start;
    15.  
    16. int height = yPan / dy ;
    17. int width = xPan / dx ;
    18. QSize plotSize (width,height);
    19.  
    20. auto rasterData = p_data->m_spectro->data();
    21.  
    22. QSurfaceDataArray *dataArray = new QSurfaceDataArray;
    23. dataArray->reserve(height);
    24. for (int i = 0; i < height; i++) {
    25. QSurfaceDataRow *newRow = new QSurfaceDataRow(width);
    26. for (int j = 0; j < width; j++) {
    27. float x = float(j) * dx + range.start;
    28. float y = float(i) * dy + p_data->m_yRange.start;
    29. float z = rasterData->value(x,y) + p_data->m_zOffset;
    30. (*newRow)[j].setPosition(QVector3D(x, z,y));
    31. }
    32. *dataArray << newRow;
    33. }
    34.  
    35. dataProxy()->resetArray(dataArray);
    36.  
    37.  
    38. QImage plotImage = QImage(plotSize,QImage::Format::Format_RGB32);
    39. plotImage.fill(QColor(Qt::white));
    40. QPainter painter(&plotImage);
    41.  
    42.  
    43. xMap.setPaintInterval(0, plotSize.width());
    44. xMap.setScaleInterval(range.start,range.end);
    45.  
    46. yMap.setPaintInterval(plotSize.height(), 0); // inverted !!!
    47. yMap.setScaleInterval(p_data->m_yRange.start,p_data->m_yRange.end);
    48.  
    49. p_data->m_spectro->draw(&painter, xMap, yMap, QRect(QPoint(0, 0), plotSize));
    50. setTexture(plotImage);
    51. }
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to baray98 for this useful post:

    d_stranz (12th February 2021)

Similar Threads

  1. Q3DSurface rendering on large values on an axis issue
    By baray98 in forum Qt Programming
    Replies: 0
    Last Post: 24th June 2019, 23:32
  2. rotation Q3DSurface and Draw line in Q3DSurface
    By alinayebi9080 in forum Qt Tools
    Replies: 0
    Last Post: 20th April 2017, 15:19
  3. Replies: 1
    Last Post: 1st February 2009, 19:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.