I am unable to do 2D vtk renders in QT without having override errors: Vtk charts break in QT, "no override found for 'vtkContextDevice2D".
While trying to solve this I have been reading about the vtkContextView and vtkGenericOpenGLRenderWindow classes.
vtkGenericOpenGLRenderWindow:
vtkGenericOpenGLRenderWindow provides a skeleton for implementing a render window using one's own OpenGL context and drawable. To be effective, one must register an observer for WindowMakeCurrentEvent, WindowIsCurrentEvent and WindowFrameEvent.
vtkContextView:
This class is derived from vtkRenderViewBase and provides a view of a vtkContextScene, with a default interactor style, renderer etc. It is the simplest way to create a vtkRenderWindow and display a 2D scene inside of it.
I do not understand how the vtkContextView works with OpenGL and was wondering if someone could help explain their relation to one another, and how the context view works.
Also, is there any other way to do 2D vtk renders without the using the context view? I cannot find any exmaples of 2D vtk renders in QT, any advice on how to do 2D renders of vtk in QT will be greatly appreciated.
Current Attempt to render 2D vtk chart:
view->SetRenderWindow(this->qvtkWidgetRight->GetRenderWindow());
view->SetInteractor(this->qvtkWidgetRight->GetInteractor());
Additional Code in main file:
QSurfaceFormat::setDefaultFormat(QVTKOpenGLNativeWidget::defaultFormat());
Additional Info: Win64 on 64bit machine, vtk8.2.0, Qt5.13.0, compiled/built in MCVS2017(Release x64) with cmake3.15.0(3D vtk renders work fine)
Finally figured it out with the help of VTK forums. I simply did not have vtkRenderingContextOpenGL2 in my CMake file(updated code too, had it backwards).
Related
How to put a label or button into qt3d window? Is it possible? Havent seen any example... I was trying to simply put qt3d in windowcontainer, assign layout to it and layout->addWiget() but it just doesnt work.
I know this is a farily old question but I wanted to give a more detailed answer if anyone else stumbles across this.
I implemented a Qt3D widget which you can find here. Unfortunately it relies on a method to obtain the texture id from QAbstractTexture which is only available from Qt >= 5.13 so that's the minimum version you have to use.
createWindowContainer draws the respective window above everything else. So you'll never be able to draw any buttons inside the container.
You can of course have buttons and everything else around your containered 3D window. But that's specifically not what you wanted.
You can use Dear ImGui - and it's Qt3D integration. ImGui is used to draw GUI elements using vertices in 3D environments.
Of course you can always use QML - there you should be able to place buttons inside the 3D view.
you have both label and (radio)buttons on the first example for C++ into the QT3d documentation, refer to Qt 3D: Basic Shapes C++ Example
QExtrudedTextGeometry seems to be the class for 3D text
I am new to Qt and I want to use Qt to make interactive geometry programs using CGAL. I would like the user to input, say points, segments, using the mouse and then push a button to get a CGAL algorithm working on the input.
My environment is CGAL 4.5, Qt 5.6 and QtCreator 3.6.1 on an Ubuntu 14.04 machine.
CGAL has builtin support for its objects to be
rendered using the QtGraphicsViewFramework (http://doc.cgal.org/latest/GraphicsView/index.html )
I don't know how to render CGAL objects -- points, lines, rays, polygons -- onto a Qt window. The page I linked to above assumes a knowledge of Qt to get an application working, and so is not helpful to a Qt beginner.
Thus far, I have created a Qt widgets application project using QtCreator. From what I know, I need to modify the mainwindow.ui file graphically inside QtCreator by dragging and dropping different kinds of widgets onto it and then map signals calling CGAL functions onto slots of whatever the drawing canvas widget will be. (Is this correct? I am shaky on the signals and slots mechanism)
MY QUESTION IS....which widget do I place onto the window as a drawing canvas? Two relevant widgets seem to be GraphicsView and OpenGL widgets
under the DisplayWidgets menu. But how do I use them?
I have no CGAL experience, but I can give you some Qt-related hints:
Use the QGraphicsView + QGraphicsScene. If you want, you can enable OpenGL support like this:
QGraphicsView view = new QGraphicsView(parentWindow);
view->setViewport(new QOpenGLWidget(view));
To draw CGAL objects you have to use either provided graphics item classes (CGAL::Qt::TriangulationGraphicsItem, CGAL::Qt::VoronoiGraphicsItem, ...) or derive your own from the CGAL::Qt::GraphicsItem. To add an item to the scene, use the QGraphicsScene::addItem() method.
To navigate (pan + zoom) the view, CGAL provides the CGAL::Qt::GraphicsViewNavigation class. This is how to use it:
CGAL::Qt::GraphicsViewNavigation* navFilter = new CGAL::Qt::GraphicsViewNavigation(view);
view->viewport()->installEventFilter(navFilter);
I have been looking for ways to render a 3d scene using Qt QML controls. I saw there is a framebuffer example which uses Canvas3D control to get OpenGL 3d scene rendered. However this example uses JavaScript for the rendering logic.
I was looking for a way to do the same but via a C++ class. Is there any way to do so? Or any example available?
Ideally, I would like to use 3rd party renderer to create a scene. Any ideas?
I am building a c++ maze project for school and want to create a 2d graphics window in c++ that will let me render something like this http://www.dreamincode.net/forums/uploads/monthly_07_2011/post-114496-13104660729008.png.
Can anyone suggest a 2d graphics library to use? I have looked into openGL but am worried that the geometry necessary is too complicated for what I need. Of course I may be overlooking some things.
I am working in Xcode on OS X and if the library is not multiplatform that is okay. Can anyone suggest me something?
The Qt framework is a cross-platform solution for building applications.
There is a basic drawing example that shows how to use basic graphic primitives:
The core of the technique consists in reimplementing a widget's paintEvent() method to control how it is displayed (painted) on the screen. The QPainter class provides many drawing methods to suit your needs.
Since cross-platform is not a problem, just use Quartz or SpriteKit. Quartz is general 2D drawing, SpriteKit is specifically for games. All the docs you can access directly in Xcode through the documentation window, and Apple provides a bunch of sample code too.
i'm currently working on a voxel editor and everything is going fine.
I have my SFML windows and my model to work with. I was just wondering if it was possible with SFML to set the 3D context to a certain specefic size.
I'm asking this because my model is currently shown on the screen with not problem at all, except that now, I want to create some options settings with SFML and my button will on my 3D model. Like, I would like 75% of the left side of my window to be my 3D context and the 25% at the right to be blank with space to fill in my buttons.
To do what you want to do, I believe what you're looking for is this: http://www.sfml-dev.org/documentation/2.0/classsf_1_1View.php#details
I think the context is attached to the window in general. Also be aware that SFML is for 2D graphics. Once you want 3D rendering, you're going to need to use openGL directly. SFML is a wrapper for openGL calls so there's no problem with using SFML to help set up and manage things, and openGL directly for rendering needs.
http://www.sfml-dev.org/tutorials/2.0/window-opengl.php
try:
glViewport(x,y,width,height);
source: https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glViewport.xml