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 // 31 // W A R N I N G 32 // ------------- 33 // 34 // This file is not part of the QtDataVisualization API. It exists purely as an 35 // implementation detail. This header file may change from version to 36 // version without notice, or even be removed. 37 // 38 // We mean it. 39 40 #ifndef Q3DBARSCONTROLLER_p_H 41 #define Q3DBARSCONTROLLER_p_H 42 43 #include "datavisualizationglobal_p.h" 44 #include "abstract3dcontroller_p.h" 45 46 QT_BEGIN_NAMESPACE_DATAVISUALIZATION 47 48 class Bars3DRenderer; 49 class QBar3DSeries; 50 51 struct Bars3DChangeBitField { 52 bool multiSeriesScalingChanged : 1; 53 bool barSpecsChanged : 1; 54 bool selectedBarChanged : 1; 55 bool rowsChanged : 1; 56 bool itemChanged : 1; 57 bool floorLevelChanged : 1; 58 Bars3DChangeBitFieldBars3DChangeBitField59 Bars3DChangeBitField() : 60 multiSeriesScalingChanged(true), 61 barSpecsChanged(true), 62 selectedBarChanged(true), 63 rowsChanged(false), 64 itemChanged(false), 65 floorLevelChanged(false) 66 { 67 } 68 }; 69 70 class QT_DATAVISUALIZATION_EXPORT Bars3DController : public Abstract3DController 71 { 72 Q_OBJECT 73 74 public: 75 struct ChangeItem { 76 QBar3DSeries *series; 77 QPoint point; 78 }; 79 struct ChangeRow { 80 QBar3DSeries *series; 81 int row; 82 }; 83 84 private: 85 Bars3DChangeBitField m_changeTracker; 86 QVector<ChangeItem> m_changedItems; 87 QVector<ChangeRow> m_changedRows; 88 89 // Interaction 90 QPoint m_selectedBar; // Points to row & column in data window. 91 QBar3DSeries *m_selectedBarSeries; // Points to the series for which the bar is selected in 92 // single series selection cases. 93 QBar3DSeries *m_primarySeries; // Category axis labels are taken from the primary series 94 95 // Look'n'feel 96 bool m_isMultiSeriesUniform; 97 bool m_isBarSpecRelative; 98 GLfloat m_barThicknessRatio; 99 QSizeF m_barSpacing; 100 float m_floorLevel; 101 102 // Rendering 103 Bars3DRenderer *m_renderer; 104 105 public: 106 explicit Bars3DController(QRect rect, Q3DScene *scene = 0); 107 ~Bars3DController(); 108 109 virtual void initializeOpenGL(); 110 virtual void synchDataToRenderer(); 111 112 void setMultiSeriesScaling(bool uniform); 113 bool multiSeriesScaling() const; 114 115 // bar thickness, spacing between bars, and is spacing relative to thickness or absolute 116 // y -component sets the thickness/spacing of z -direction 117 // With relative 0.0f means side-to-side, 1.0f = one thickness in between 118 void setBarSpecs(GLfloat thicknessRatio = 1.0f, 119 const QSizeF &spacing = QSizeF(1.0, 1.0), 120 bool relative = true); 121 GLfloat barThickness(); 122 QSizeF barSpacing(); 123 bool isBarSpecRelative(); 124 void setFloorLevel(float level); 125 float floorLevel() const; 126 selectedSeries()127 inline QBar3DSeries *selectedSeries() const { return m_selectedBarSeries; } 128 129 void setSelectionMode(QAbstract3DGraph::SelectionFlags mode); 130 void setSelectedBar(const QPoint &position, QBar3DSeries *series, bool enterSlice); 131 virtual void clearSelection(); 132 133 virtual void handleAxisAutoAdjustRangeChangedInOrientation( 134 QAbstract3DAxis::AxisOrientation orientation, bool autoAdjust); 135 virtual void handleSeriesVisibilityChangedBySender(QObject *sender); 136 virtual void handlePendingClick(); 137 138 static QPoint invalidSelectionPosition(); 139 140 virtual void setAxisX(QAbstract3DAxis *axis); 141 virtual void setAxisZ(QAbstract3DAxis *axis); 142 143 virtual void setPrimarySeries(QBar3DSeries *series); 144 virtual QBar3DSeries *primarySeries() const; 145 virtual void addSeries(QAbstract3DSeries *series); 146 virtual void removeSeries(QAbstract3DSeries *series); 147 virtual void insertSeries(int index, QAbstract3DSeries *series); 148 virtual QList<QBar3DSeries *> barSeriesList(); 149 150 virtual void handleAxisRangeChangedBySender(QObject *sender); 151 virtual void adjustAxisRanges(); 152 153 public Q_SLOTS: 154 void handleArrayReset(); 155 void handleRowsAdded(int startIndex, int count); 156 void handleRowsChanged(int startIndex, int count); 157 void handleRowsRemoved(int startIndex, int count); 158 void handleRowsInserted(int startIndex, int count); 159 void handleItemChanged(int rowIndex, int columnIndex); 160 void handleDataRowLabelsChanged(); 161 void handleDataColumnLabelsChanged(); 162 163 Q_SIGNALS: 164 void primarySeriesChanged(QBar3DSeries *series); 165 void selectedSeriesChanged(QBar3DSeries *series); 166 167 protected: 168 virtual QAbstract3DAxis *createDefaultAxis(QAbstract3DAxis::AxisOrientation orientation); 169 170 private: 171 void adjustSelectionPosition(QPoint &pos, const QBar3DSeries *series); 172 173 Q_DISABLE_COPY(Bars3DController) 174 }; 175 176 QT_END_NAMESPACE_DATAVISUALIZATION 177 178 #endif 179