IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

Custom Items Example

Adding custom items to a surface graph.

This documentation was introduced in QtDataVisualization 1.1.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

Custom Items Example▲

The custom items example shows how to add your own custom meshes as items to a graph, and how to remove them.

Image non disponible

Running the Example▲

To run the example from http://, open the Welcome mode and select the example from Examples. For more information, visit http://.

Adding Custom Meshes to the Application▲

We'll add the meshes in a resource file:

 
Sélectionnez
<RCC>
...
<qresource prefix="/items">
    <file>refinery.obj</file>
    <file>oilrig.obj</file>
</qresource>
</RCC>

Adding Custom Item to a Graph▲

In this example we do not have specific textures for our meshes, so we'll just create a small https:// and fill it with a single color:

 
Sélectionnez
QImage color = QImage(2, 2, QImage::Format_RGB32);
color.fill(Qt::red);

Then we'll specify the position for the item in a variable. This way we'll be able to use it later for removing the correct item:

 
Sélectionnez
QVector3D positionOne = QVector3D(39.0f, 77.0f, 19.2f);

Then we'll create a new https:// with all the parameters:

 
Sélectionnez
QCustom3DItem *item = new QCustom3DItem(":/items/oilrig.obj", positionOne,
                                        QVector3D(0.025f, 0.025f, 0.025f),
                                        QQuaternion::fromAxisAndAngle(0.0f, 1.0f, 0.0f, 45.0f),
                                        color);

And finally we'll just add the item:

 
Sélectionnez
m_graph->addCustomItem(item);

Removing Custom Item from a Graph▲

We'll just call removeCustomItemAt() with the position of the item:

 
Sélectionnez
m_graph->removeCustomItemAt(positionOne);

Removing a custom item from the graph also deletes it. If you want to preserve the item, you need to use releaseCustomItem() method instead.

Example Contents▲

 

List of Files▲

Files:

List of Files▲
  • customitems/customitemgraph.cpp

  • customitems/customitemgraph.h

  • customitems/customitems.pro

  • customitems/customitems.qrc

  • customitems/main.cpp

List of Files▲

Images:

List of Files▲
  • customitems/layer_1.png

  • customitems/layer_2.png

  • customitems/layer_3.png

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+   

Ce document est disponible sous la licence https:// telle que publiée par la Free Software Foundation.