QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
Viewer3DInstancing.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QByteArray>
4#include <QtCore/QList>
5#include <QtGui/QColor>
6#include <QtGui/QQuaternion>
7#include <QtGui/QVector3D>
8#include <QtQmlIntegration/QtQmlIntegration>
9#include <QtQuick3D/QQuick3DInstancing>
10
11class Viewer3DInstancing : public QQuick3DInstancing
12{
13 Q_OBJECT
14 QML_ELEMENT
15 Q_PROPERTY(int count READ count NOTIFY countChanged)
17
19
20public:
21 explicit Viewer3DInstancing(QQuick3DObject *parent = nullptr);
22
23 Q_INVOKABLE void clear();
24 Q_INVOKABLE void addEntry(const QVector3D &position,
25 const QVector3D &scale,
26 const QQuaternion &rotation,
27 const QColor &color);
28 Q_INVOKABLE void addLineSegment(const QVector3D &p1,
29 const QVector3D &p2,
30 float lineWidth,
31 const QColor &color);
32 int count() const;
33
34 int selectedIndex() const;
35 void setSelectedIndex(int index);
36
37signals:
40
41protected:
42 QByteArray getInstanceBuffer(int *instanceCount) override;
43
44private:
45 struct InstanceEntry {
46 QVector3D position;
47 QVector3D scale;
48 QQuaternion rotation;
49 QColor color;
50 };
51
52 static inline const QColor kHighlightColor{255, 255, 0};
53
54 QList<InstanceEntry> _entries;
55 QByteArray _instanceData;
56 bool _dirty = false;
57 int _selectedIndex = -1;
58};
Q_INVOKABLE void clear()
QByteArray getInstanceBuffer(int *instanceCount) override
Q_INVOKABLE void addEntry(const QVector3D &position, const QVector3D &scale, const QQuaternion &rotation, const QColor &color)
friend class Viewer3DInstancingTest
void selectedIndexChanged()
void setSelectedIndex(int index)
Q_INVOKABLE void addLineSegment(const QVector3D &p1, const QVector3D &p2, float lineWidth, const QColor &color)