Download - Qt coin3d soqt
![Page 1: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/1.jpg)
INTRODUCTION To
Qt
![Page 2: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/2.jpg)
What is Qt?
❏Cross-platform application development framework.
❏Used to create graphical user interfaces.❏ It can be used with several different
programming languages.❏ “t” in Qt refers to toolkit which defines Qt
much better. Therefore, it can effectively be defined as a set of tools.
![Page 3: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/3.jpg)
Qt TOOLS
❏ The main component is a set of libraries, written natively in C++. These libraries include: the core library providing the most important stuff, the GUI library providing the GUI components, the XML library.
❏ Meta Object Compiler(moc) used to handle Qt’s C++ extensions.This extends C++ a little bit, adding nice features like the signals/slots mechanism
❏ The GUI designer tool and the UIC. Qt Designer is a graphical tool to create GUIs visually and save them to XML files, and the UIC is a command-line tool to translate those XML files to C++ code.
![Page 4: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/4.jpg)
❏Qt Linguist, tool to internationalize applications.Qt Linguist is a graphical tool for translator to edit those XML files and provide translations.
❏ The qmake tool, used to automate build process, so you don't have to run MOC, C++ compiler, UIC and other things manually.
❏ The Qt Creator, a graphical IDE to integrate all the stuff described above into a single environment.
![Page 5: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/5.jpg)
qmake helps to create .pro file
![Page 6: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/6.jpg)
Creating a Qt project
![Page 7: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/7.jpg)
Go to File and select New
![Page 8: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/8.jpg)
Select
![Page 9: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/9.jpg)
![Page 10: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/10.jpg)
Files generated
![Page 11: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/11.jpg)
Examples
![Page 12: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/12.jpg)
![Page 13: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/13.jpg)
![Page 14: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/14.jpg)
![Page 15: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/15.jpg)
![Page 16: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/16.jpg)
Similarly a 2D graphic such as a circle,ellipse
can be built
![Page 17: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/17.jpg)
The code uses QPainter on QMainWindow. Circle drawing is done during gui decoration process , it is not drawn as an animation.Drawing empty circle on
QMainWindow involves subclassing of QMainWindow and overriding
paintEvent(QPaintEvent*) method.
![Page 18: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/18.jpg)
![Page 19: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/19.jpg)
using Coin3D and SoQt
3-D Graphics in Qt
![Page 20: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/20.jpg)
❏Coin3D is a high level 3D graphics toolkit for developing cross-platform 3D visualizations.
❏ It uses scene graph data structures to render 3D graphics.
❏ Based on the de facto standard Open Inventor, Coin3D is a set of libraries for creating 3D graphics applications.
![Page 21: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/21.jpg)
Coin3D
Few Steps to install
![Page 22: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/22.jpg)
1. Download Coin-3.1.3.tar.gz fom https://bitbucket.org/Coin3D/coin/downloads.
2. Next unzip the file using the following commands:o cd /tmpo gzip -cd Coin-3.1.3.tar.gz | tar xvf -o mkdir coin-build
3. Run configure from the build directory:cd coin-build4. ../Coin-3.1.3/configure5. Build the Coin library:6. make7. Install the Coin library:8. make install
![Page 23: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/23.jpg)
Just install:libsoqt40-dev
SoQt is a library which provides bridge between Coin3D visualistion and Qt 2D Graphical Interface.
![Page 24: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/24.jpg)
Linking
Add in the pro file:
LIBS += -lCoin3D -lSoQt
![Page 25: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/25.jpg)
Open Inventor
Open Inventor is a “scenegraph“ graphics API: All visible objects are stored in a scenegraph
![Page 26: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/26.jpg)
Capabilities of Open Inventor
❏ Easy construction of 3D scenes❏User interaction❏ Animation
![Page 27: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/27.jpg)
Scenegraph Anatomy
There are three kinds of nodes:
Group nodes: allow construction of trees
Property nodes: change the color / location / ... of the next object
Shapes: visible objects.
![Page 28: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/28.jpg)
Common node types
❏Group nodes
SoGroup: SoSeparator..❏ Property nodes
Transform: SoTransform, SoRotation, ...
Appearance: SoMaterial….❏ Shape nodes
SoShape SoCone, SoCube,
![Page 29: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/29.jpg)
Scene objects
class name prefix: So (scene object)❏ derived from SoNode❏ can be inserted directly into the scenegraph
Example:
root->addChild(new SoSphere)
![Page 30: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/30.jpg)
# <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoCube.h>
int main(int argc, char ** argv)
{
QWidget * mainwin = SoQt::init(argc, argv, argv[0]);
SoSeparator * root = new SoSeparator;
root->ref();
SoCube *cube = new SoCube;
r
![Page 31: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/31.jpg)
root->addChild(cube);
SoQtExaminerViewer * eviewer = new
SoQtExaminerViewer(mainwin);
eviewer->setSceneGraph(root);
eviewer->show();
SoQt::show(mainwin);
SoQt::mainLoop();
root->unref();
delete eviewer;
return 0;}
}
![Page 32: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/32.jpg)
![Page 33: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/33.jpg)
#include <Inventor/Qt/SoQt.h>: The SoQt class takes care of Qt initialisation.
# include<Inventor/Qt/viewers/SoQtExaminerViewer.h>It is the general purpose viewer to view the 3D object generated.
#include <Inventor/nodes/SoSeparator.h>
It is subclass of SoGroup class.
#include <Inventor/nodes/SoCube.h>This is the node for cube shape. It comes under the category of shape nodes.
![Page 34: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/34.jpg)
❏ QWidget * mainwin = SoQt::init(argc, argv, argv[0]);
SoQt ::init with a string creates a QApplication and its main window, and returns its window handle.
❏ SoSeparator * root = new SoSeparator;
root->ref();
The root node of the scene graph is created here.❏ SoCube *cube = new SoCube;
root->addChild(cube);
A cube is added to the scene as a child to the root node.
![Page 35: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/35.jpg)
❏ SoQtExaminerViewer(mainwin);
eviewer->setSceneGraph(root);
eviewer->show();
The ExaminerViewer class of the viewer is used for display of objects.
❏ SoQt::show(mainwin);
This pops up the main window.❏ SoQt::mainLoop();
Cleans up all static data allocated by the SoQt library on initialization.
![Page 36: Qt coin3d soqt](https://reader036.vdocuments.us/reader036/viewer/2022062312/555ad9b2d8b42a024a8b4e90/html5/thumbnails/36.jpg)
Thank You