| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt Data Visualization module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 or (at your option) any later version |
| 20 | ** approved by the KDE Free Qt Foundation. The licenses are as published by |
| 21 | ** the Free Software Foundation and appearing in the file LICENSE.GPL3 |
| 22 | ** included in the packaging of this file. Please review the following |
| 23 | ** information to ensure the GNU General Public License requirements will |
| 24 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 25 | ** |
| 26 | ** $QT_END_LICENSE$ |
| 27 | ** |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | #ifndef VOLUMETRICMODIFIER_H |
| 31 | #define VOLUMETRICMODIFIER_H |
| 32 | |
| 33 | #include <QtDataVisualization/q3dscatter.h> |
| 34 | #include <QtDataVisualization/qcustom3dvolume.h> |
| 35 | #include <QtCore/QTimer> |
| 36 | #include <QtGui/QRgb> |
| 37 | #include <QtWidgets/QLabel> |
| 38 | #include <QtWidgets/QSlider> |
| 39 | #include <QtWidgets/QRadioButton> |
| 40 | |
| 41 | using namespace QtDataVisualization; |
| 42 | |
| 43 | class VolumetricModifier : public QObject |
| 44 | { |
| 45 | Q_OBJECT |
| 46 | public: |
| 47 | explicit VolumetricModifier(Q3DScatter *scatter); |
| 48 | ~VolumetricModifier(); |
| 49 | |
| 50 | void setFpsLabel(QLabel *fpsLabel); |
| 51 | void setMediumDetailRB(QRadioButton *button); |
| 52 | void setHighDetailRB(QRadioButton *button); |
| 53 | void setSliceLabels(QLabel *xLabel, QLabel *yLabel, QLabel *zLabel); |
| 54 | void setAlphaMultiplierLabel(QLabel *label); |
| 55 | |
| 56 | public Q_SLOTS: |
| 57 | void sliceX(int enabled); |
| 58 | void sliceY(int enabled); |
| 59 | void sliceZ(int enabled); |
| 60 | void adjustSliceX(int value); |
| 61 | void adjustSliceY(int value); |
| 62 | void adjustSliceZ(int value); |
| 63 | void handleFpsChange(qreal fps); |
| 64 | void handleTimeout(); |
| 65 | void toggleLowDetail(bool enabled); |
| 66 | void toggleMediumDetail(bool enabled); |
| 67 | void toggleHighDetail(bool enabled); |
| 68 | void setFpsMeasurement(bool enabled); |
| 69 | void setSliceSliders(QSlider *sliderX, QSlider *sliderY, QSlider *sliderZ); |
| 70 | void changeColorTable(int enabled); |
| 71 | void setPreserveOpacity(bool enabled); |
| 72 | void setTransparentGround(bool enabled); |
| 73 | void setUseHighDefShader(bool enabled); |
| 74 | void adjustAlphaMultiplier(int value); |
| 75 | void toggleAreaAll(bool enabled); |
| 76 | void toggleAreaMine(bool enabled); |
| 77 | void toggleAreaMountain(bool enabled); |
| 78 | void setDrawSliceFrames(int enabled); |
| 79 | |
| 80 | private: |
| 81 | |
| 82 | void initHeightMap(QString fileName, QVector<uchar> &layerData); |
| 83 | void initMineShaftArray(); |
| 84 | int createVolume(int textureSize, int startIndex, int count, |
| 85 | QVector<uchar> *textureData); |
| 86 | int excavateMineShaft(int textureSize, int startIndex, int count, |
| 87 | QVector<uchar> *textureData); |
| 88 | void excavateMineBlock(int textureSize, int dataIndex, int size, QVector<uchar> *textureData); |
| 89 | void handleSlicingChanges(); |
| 90 | |
| 91 | Q3DScatter *m_graph; |
| 92 | QCustom3DVolume *m_volumeItem; |
| 93 | int m_sliceIndexX; |
| 94 | int m_sliceIndexY; |
| 95 | int m_sliceIndexZ; |
| 96 | bool m_slicingX; |
| 97 | bool m_slicingY; |
| 98 | bool m_slicingZ; |
| 99 | QLabel *m_fpsLabel; |
| 100 | QRadioButton *m_mediumDetailRB; |
| 101 | QRadioButton *m_highDetailRB; |
| 102 | QVector<uchar> *m_lowDetailData; |
| 103 | QVector<uchar> *m_mediumDetailData; |
| 104 | QVector<uchar> *m_highDetailData; |
| 105 | QTimer m_timer; |
| 106 | int m_mediumDetailIndex; |
| 107 | int m_highDetailIndex; |
| 108 | int m_mediumDetailShaftIndex; |
| 109 | int m_highDetailShaftIndex; |
| 110 | QSlider *m_sliceSliderX; |
| 111 | QSlider *m_sliceSliderY; |
| 112 | QSlider *m_sliceSliderZ; |
| 113 | QVector<QRgb> m_colorTable1; |
| 114 | QVector<QRgb> m_colorTable2; |
| 115 | bool m_usingPrimaryTable; |
| 116 | QLabel *m_sliceLabelX; |
| 117 | QLabel *m_sliceLabelY; |
| 118 | QLabel *m_sliceLabelZ; |
| 119 | QLabel *m_alphaMultiplierLabel; |
| 120 | QVector<uchar> m_magmaLayer; |
| 121 | QVector<uchar> m_waterLayer; |
| 122 | QVector<uchar> m_groundLayer; |
| 123 | QVector<QPair<QVector3D, QVector3D> > m_mineShaftArray; |
| 124 | }; |
| 125 | |
| 126 | #endif |
| 127 | |