QGIS API Documentation 3.41.0-Master (1deb1daf037)
Loading...
Searching...
No Matches
qgschunkboundsentity_p.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgschunkboundsentity_p.cpp
3 --------------------------------------
4 Date : July 2017
5 Copyright : (C) 2017 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17#include "moc_qgschunkboundsentity_p.cpp"
18
19#include <Qt3DExtras/QPhongMaterial>
20
21#include "qgsaabb.h"
22#include "qgs3dwiredmesh_p.h"
23#include "qgsbox3d.h"
24#include "qgsgeotransform.h"
25
26
28
29QgsChunkBoundsEntity::QgsChunkBoundsEntity( const QgsVector3D &vertexDataOrigin, Qt3DCore::QNode *parent )
30 : Qt3DCore::QEntity( parent )
31 , mVertexDataOrigin( vertexDataOrigin )
32{
33 mAabbMesh = new Qgs3DWiredMesh;
34 addComponent( mAabbMesh );
35
36 Qt3DExtras::QPhongMaterial *bboxesMaterial = new Qt3DExtras::QPhongMaterial;
37 bboxesMaterial->setAmbient( Qt::red );
38 addComponent( bboxesMaterial );
39
40 QgsGeoTransform *transform = new QgsGeoTransform;
41 transform->setGeoTranslation( mVertexDataOrigin );
42 addComponent( transform );
43}
44
45void QgsChunkBoundsEntity::setBoxes( const QList<QgsBox3D> &bboxes )
46{
47 QList<QgsAABB> aabbBoxes;
48 for ( const QgsBox3D &box : bboxes )
49 {
50 aabbBoxes << QgsAABB::fromBox3D( box, mVertexDataOrigin );
51 }
52 mAabbMesh->setVertices( aabbBoxes );
53}
54
static QgsAABB fromBox3D(const QgsBox3D &box3D, const QgsVector3D &origin)
Constructs bounding box from QgsBox3D by subtracting origin 3D vector.
Definition qgsaabb.h:48
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:43
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition qgsvector3d.h:31