Is it possible render stl files on QtGlWidget?



  • Well, is it? If yes, can you give me how to start? (Tutorials, websites, etc)
    Thanks!


  • Lifetime Qt Champion

    Hi,

    Maybe with the use of the Qt3D module



  • You may consider high level 3D visualization libraries.
    They take some time to learn, but usually have higher level of abstraction than OpenGl/DirectX, etc.

    Free to use : VTK, Coin3D
    http://www.vtk.org/download/

    VTK has Qt binding, as far as I can recall Coin3D has it too.



  • We are using OpenCascade for this. There are already Qt examples (IESample) included for having a quick solution. OCC itself is pretty powerful but can be also very complex in further development. It is also not a slim package but a full CA* framework which results in a lot of additional libraries.



  • @SGaist The command:git clone --recursive https://code.qt.io/qt-creator/qt-creator.git from this tutorial: http://wiki.qt.io/Building_Qt_Creator_from_Git is not found.
    Where i get the qt3D?
    Thanks


  • Lifetime Qt Champion

    The clone URL is correct and working.

    You can find Qt3D at the same place: https://code.qt.io/qt/qt3d.git



  • This post is deleted!


  • @SGaist
    Please, help me. rs
    I downloaded the qt3d for git, and try to add to my qt5 lib. but after qmake, when i run make this error appears:
    In file included from ../../include/Qt3DCore/5.5.0/Qt3DCore/private/qabstractaspect_p.h:1:0,
    from /home/lays/qt3d/src/core/aspects/qabstractaspect.cpp:40:
    ../../include/Qt3DCore/5.5.0/Qt3DCore/private/../../../../../../../../qt3d/src/core/aspects/qabstractaspect_p.h:40:31: fatal error: private/qobject_p.h: No such file or directory
    #include <private/qobject_p.h>
    ^
    compilation terminated.
    make[2]: *** [.obj/qabstractaspect.o] Error 1
    make[2]: Leaving directory /home/lays/QtEverywhere/qtbase/bin/src/core' make[1]: *** [sub-core-make_first] Error 2 make[1]: Leaving directory/home/lays/QtEverywhere/qtbase/bin/src'
    make: *** [sub-src-make_first] Error 2
    lays@lays:~/QtEverywhere/qtbase/bin$

    Ps: My qt is build static and is the opensource license. (ubuntu 14)
    How do i fix it?
    Thanks!


  • Lifetime Qt Champion

    Which version of Qt 5 do you have installed ?
    Qt3D needs at least Qt 5.5, if you use the Qt 5.5RC package, Qt3D is included as tech preview.



  • @alex_malyu The binding of VTK with QT(5.4.2 or superior) is no supported. The Widget is only on qt version 5.0.1. On Qt Designer 4 i can load the widget, but i cant use in QtCreator.
    i'm following this tutorial: http://www.vtk.org/Wiki/VTK/Tutorials/QtSetup

    "NOTE: This does NOT work with versions of QtCreator built against Qt 5.0.1. At the time of this writing, the release with the package of Qt Libraries + Qt Creator is built against Qt 5.0.1, while the release of the stand alone QtCreator is built against Qt 4.8.3. The Designer plugin will simply not be loaded."

    and @SGaist i'm downloading again qt5 for git, i will try to make again. thanks for the tip.

    If anyone can give me any tip on how to read a stl file with qt, i really thanks.

    My config about QtCreator:
    Qt Creator 3.4.1 (opensource)
    Based on Qt 5.4.2 (GCC 4.6.1, 64 bit)
    Built on May 28 2015 18:39:12
    From revision 29d81424a2



  • I am not using 5.4.2.+ so I might be wrong, but
    as far as I understand all these talks are about PLUGIN.

    And purpose of the plugin is to display QVTKWidget in the designer.
    This does not work well anyway unless you build everything yourself, cause to work require Qt and Creator to be built with the same chain which at least for Windows would be a rare case.

    If you need to place QVtkWidget (or any other widget) in the designer simply place QWidget and then promote it.
    You will have to set specific for such widget properties in the code, but I believe it is the best practice anyway.



  • @alex_malyu
    I found out that. Not necessarily need the widget. But I'm having trouble compiling. I picked up the function to read the STL's wiki VTK and edited to work on my program, but the compilation does not end. Are the following errors:

    'brprint3d.o: In function readstl(QString)': ../Pandora/brprint3d.cpp:(.text+0x4927): undefined reference tovtkSTLReader::New()'
    ../Pandora/brprint3d.cpp:(.text+0x4939): undefined reference to vtkSmartPointerBase::vtkSmartPointerBase(vtkObjectBase*, vtkSmartPointerBase::NoReference const&)' ../Pandora/brprint3d.cpp:(.text+0x4965): undefined reference tovtkPolyDataMapper::New()'
    ../Pandora/brprint3d.cpp:(.text+0x4977): undefined reference to vtkSmartPointerBase::vtkSmartPointerBase(vtkObjectBase*, vtkSmartPointerBase::NoReference const&)' ../Pandora/brprint3d.cpp:(.text+0x4992): undefined reference tovtkAlgorithm::GetOutputPort(int)'
    ../Pandora/brprint3d.cpp:(.text+0x49a0): undefined reference to vtkActor::New()' ../Pandora/brprint3d.cpp:(.text+0x49b2): undefined reference tovtkSmartPointerBase::vtkSmartPointerBase(vtkObjectBase*, vtkSmartPointerBase::NoReference const&)'
    ../Pandora/brprint3d.cpp:(.text+0x49cd): undefined reference to vtkRenderer::New()' ../Pandora/brprint3d.cpp:(.text+0x49df): undefined reference tovtkSmartPointerBase::vtkSmartPointerBase(vtkObjectBase*, vtkSmartPointerBase::NoReference const&)'
    ../Pandora/brprint3d.cpp:(.text+0x49e4): undefined reference to vtkRenderWindow::New()' ../Pandora/brprint3d.cpp:(.text+0x49f6): undefined reference tovtkSmartPointerBase::vtkSmartPointerBase(vtkObjectBase*, vtkSmartPointerBase::NoReference const&)'
    ../Pandora/brprint3d.cpp:(.text+0x4a11): undefined reference to vtkRenderWindowInteractor::New()' ../Pandora/brprint3d.cpp:(.text+0x4a26): undefined reference tovtkSmartPointerBase::vtkSmartPointerBase(vtkObjectBase*, vtkSmartPointerBase::NoReference const&)'
    ../Pandora/brprint3d.cpp:(.text+0x4a35): undefined reference to vtkRenderWindowInteractor::SetRenderWindow(vtkRenderWindow*)' ../Pandora/brprint3d.cpp:(.text+0x4a44): undefined reference tovtkRenderer::AddActor(vtkProp*)'
    ../Pandora/brprint3d.cpp:(.text+0x4a94): undefined reference to vtkSmartPointerBase::~vtkSmartPointerBase()' ../Pandora/brprint3d.cpp:(.text+0x4a9e): undefined reference tovtkSmartPointerBase::~vtkSmartPointerBase()'
    ../Pandora/brprint3d.cpp:(.text+0x4aa8): undefined reference to vtkSmartPointerBase::~vtkSmartPointerBase()' ../Pandora/brprint3d.cpp:(.text+0x4ab2): undefined reference tovtkSmartPointerBase::~vtkSmartPointerBase()'
    ../Pandora/brprint3d.cpp:(.text+0x4abc): undefined reference to vtkSmartPointerBase::~vtkSmartPointerBase()' brprint3d.o:../Pandora/brprint3d.cpp:(.text+0x4ac6): more undefined references tovtkSmartPointerBase::~vtkSmartPointerBase()' follow
    moc_brprint3d.o: In function BrPrint3D::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)': moc_brprint3d.cpp:(.text+0x269): undefined reference toBrPrint3D::readstl(QString)'
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [Pandora] Error 1'

    I dont know what to do. =S



  • I assume you are using VTK 6.
    It was redesigned and currently has a lot of modules which you have to link to if you use features from them.
    Due to number of modules it is not an easy task.

    For example vtkRenderer implementation is in vtkRenderingCore-6.1.lib ( -6.1.lib is compiler and system specific )

    When I needed to find what I need to link against I built one of the example having features I was looking for with CMake,
    then opened a project it created and looked which modules it was linked against,

    For example my vtk application is linked to:

    "vtkCommonCore-6.1.lib" "vtksys-6.1.lib" "vtkGUISupportQt-6.1.lib" "vtkCommonExecutionModel-6.1.lib" "vtkCommonDataModel-6.1.lib" "vtkCommonMath-6.1.lib" "vtkCommonMisc-6.1.lib" "vtkCommonSystem-6.1.lib" "vtkCommonTransforms-6.1.lib" "vtkFiltersExtraction-6.1.lib" "vtkFiltersCore-6.1.lib" "vtkFiltersGeneral-6.1.lib" "vtkCommonComputationalGeometry-6.1.lib" "vtkFiltersStatistics-6.1.lib" "vtkImagingFourier-6.1.lib" "vtkImagingCore-6.1.lib" "vtkalglib-6.1.lib" "vtkInteractionStyle-6.1.lib" "vtkFiltersSources-6.1.lib" "vtkRenderingCore-6.1.lib" "vtkFiltersGeometry-6.1.lib" "vtkRenderingOpenGL-6.1.lib" "vtkImagingHybrid-6.1.lib" "vtkIOImage-6.1.lib" "vtkDICOMParser-6.1.lib" "vtkIOCore-6.1.lib" "vtkzlib-6.1.lib" "vtkmetaio-6.1.lib" "vtkjpeg-6.1.lib" "vtkpng-6.1.lib" "vtktiff-6.1.lib" "vtkGUISupportQtOpenGL-6.1.lib" "vtkIOInfovis-6.1.lib" "vtkIOLegacy-6.1.lib" "vtkInfovisCore-6.1.lib" "vtklibxml2-6.1.lib" "vtkRenderingFreeTypeOpenGL-6.1.lib" "vtkRenderingFreeType-6.1.lib" "vtkfreetype-6.1.lib" "vtkftgl-6.1.lib" "vtkViewsInfovis-6.1.lib" "vtkChartsCore-6.1.lib" "vtkCommonColor-6.1.lib" "vtkRenderingContext2D-6.1.lib" "vtkFiltersImaging-6.1.lib" "vtkImagingGeneral-6.1.lib" "vtkImagingSources-6.1.lib" "vtkFiltersModeling-6.1.lib" "vtkInfovisLayout-6.1.lib" "vtkRenderingLabel-6.1.lib" "vtkViewsCore-6.1.lib" "vtkInteractionWidgets-6.1.lib" "vtkFiltersHybrid-6.1.lib" "vtkRenderingAnnotation-6.1.lib" "vtkImagingColor-6.1.lib" "vtkRenderingVolume-6.1.lib"



  • @alex_malyu I'm Deploying on Ubuntu, and i'm trying to use VTK 6.
    Well, I think I will make it clear what I need to do. I do not know if you ever heard of Repetier Host(http://www.repetier.com/), it is a framework for 3D printing. I'm doing one like it, but I'm stuck on the issue of simulation of the files on the screen. I need to render a cube (print area) and inside loading the STL file that the user chooses. Why I am suffering for days looking for something that works. My project is connected to a static Qt because when I was trying to build with shared libraries was giving me a lot of headache and nothing I did worked. When you suggested VTK seemed a great solution, but I try, I search and nothing works. For now I do not mind the VTK work with shared libraries, as long as work.



  • You can build Qt and /or VTK statically or dynamically.
    On Linux you will not be facing some problems if you mix statically/dynamically build components you might be facing on Windows.
    But your application needs to be linked against all required modules.

    Look at your VTK bin folder . It should have module named vtkRenderingCore (.a?).
    Link against it, some problems you listed should be gone.
    Then take next undefined reference.
    find which module it belongs to, link to it and so on.

    VTK people recommend to use CMAKE for your project.
    In these case it is easier to resolve dependencies.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.