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/QLoggingCategory>
4#include <QtGui/QColor>
5#include <QtGui/QQuaternion>
6#include <QtGui/QVector3D>
7#include <QtQmlIntegration/QtQmlIntegration>
8#include <QtQuick3D/QQuick3DInstancing>
9
10Q_DECLARE_LOGGING_CATEGORY(Viewer3DInstancingLog)
11
12class Viewer3DInstancing : public QQuick3DInstancing
13{
14 Q_OBJECT
15 QML_ELEMENT
16 Q_PROPERTY(int count READ count NOTIFY countChanged)
17 Q_PROPERTY(int selectedIndex READ selectedIndex WRITE setSelectedIndex NOTIFY selectedIndexChanged)
18
19 friend class Viewer3DInstancingTest;
20
21public:
22 explicit Viewer3DInstancing(QQuick3DObject *parent = nullptr);
23
24 Q_INVOKABLE void clear();
25 Q_INVOKABLE void addEntry(const QVector3D &position,
26 const QVector3D &scale,
27 const QQuaternion &rotation,
28 const QColor &color);
29 Q_INVOKABLE void addLineSegment(const QVector3D &p1,
30 const QVector3D &p2,
31 float lineWidth,
32 const QColor &color);
33 int count() const;
34
35 int selectedIndex() const;
36 void setSelectedIndex(int index);
37
38signals:
41
42protected:
43 QByteArray getInstanceBuffer(int *instanceCount) override;
44
45private:
46 struct InstanceEntry {
47 QVector3D position;
48 QVector3D scale;
49 QQuaternion rotation;
50 QColor color;
51 };
52
53 static inline const QColor kHighlightColor{255, 255, 0};
54
55 QList<InstanceEntry> _entries;
56 QByteArray _instanceData;
57 bool _dirty = false;
58 int _selectedIndex = -1;
59};
Q_DECLARE_LOGGING_CATEGORY(AndroidSerialLog)
void selectedIndexChanged()